#include <iostream> #include <Windows.h> #include <string> using namespace std; int main(void) { char x; cout << "請輸入一個字符:"; cin >> x; //利用ASCII碼表中的字符排列規律進行字母的大小寫轉換 if (x >= 'a' && x <= 'z') { //小寫字母 x = x - 'a' + 'A'; } else if (x >= 'A' && x <= 'Z') { x = x - 'A' + 'a'; } cout << x << endl; system("pause"); return 0; }
