使用C++编写程序:
题目描述
输入一个字母,若是小写字母,则变为大写输出,否则,原样输出。
输入
输入为一个字符。
输出
按题目要求输出一个字符,单独占一行。
样例输入 Copy
a
样例输出 Copy
A
程序代码如下:
#include<iostream>
#include<string>
#include<cctype>
#define ElemType string
using namespace std;
class ToggleCase
{
public:
ToggleCase(ElemType s) :Input(s) {};
void GetResult();
private:
ElemType Input;
};
inline void ToggleCase::GetResult()
{
for (int i = 0; i < Input.length(); i++)
Input[i] = toupper(Input[i]);
cout << Input;
}
int main()
{
ElemType s;
cin >> s;
ToggleCase Case(s);
Case.GetResult();
return 0;
}