求高手来解答 编写一个c++程序 题目如下

输入一个字符串存入数组a,将其复制到数组b,然后将数组b中的所有小写字母改为大写字母,再将a中字符串连接到b。比较输出a,b的字符串的大小,最后输出a,b中的字符串(不用字符串函数)
程序最好是25行,如果不行可以多

#include<iostream>
#include<string>

using namespace std;

int main()
{
string a;
string b;

cin >> a;

b = a;

for( int i = 0; i < a.length(); i++ )
if( b[ i ] <= 'z' && b[ i ] >= 'a' )
b[ i ] += 'A' - 'a';

b += a;

if( b > a )
{
cout << "b > a" << endl;
}
else if( b < a )
{
cout << "b < a" << endl;
}
else
{
cout << "b == a" << endl;
}

cout << a << endl
<< b << endl;

return 0;
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜