C++编程:读取键盘输入,知道遇到@;进行大小写转换,并回显(数字除外)

#include<iostream>
#include<cctype>
int main()
{
 using namespace std;
 char ch[30];
 cout << "输入:";
 //cin >> ch[0];
 int i = 0;
 while (i < 30 && cin>>ch[i])
 {
  if (ch[i] == '@')
   break;
  else if (islower(ch[i]))
  {
   ch[i] = toupper(ch[i]);
  }
  else if (isupper(ch[i]))
  {
   ch[i] = tolower(ch[i]);
  }
  else
   i--;
  if (++i < 30)
  {
   cout << "输入:";
  }
 }
 for (int j = 0; j < i; j++)
 {
  cout << ch[j] << endl;
 }
 cin.get();
 cin.get();
 return 0;
}

猜你喜欢

转载自blog.csdn.net/tttabcgy/article/details/80110473