解题思路:运用string函数的性质
如 string string1="123" , string2="456"; string1+=string2; 则 string1="123456";
注意事项:
题目说要循环的次数是三次,长度超过一百要输出Result String is cutted.
参考代码:
#include <iostream> #include <cstring> using namespace std; int main(){ string str1[3],str2[3]; for(int i=0;i<3;i++){ cin>>str1[i]>>str2[i]; str1[i]+=str2[i]; if(str1[i].length()>100) cout<<"Result String is cutted."<<endl; else cout<<str1[i]<<endl; } return 0; }
0.0分
3 人评分
【明明的随机数】 (C语言代码)浏览:674 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:495 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:605 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:411 |
妹子杀手的故事 (C语言代码)浏览:1218 |
三角形 (C++代码)递推浏览:755 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:500 |
【明明的随机数】 (C语言代码)浏览:785 |
Minesweeper (C语言描述,蓝桥杯)浏览:1122 |
A+B for Input-Output Practice (III) (C语言代码)浏览:564 |