題目:一個C++小題目撰寫一個程式,讀取鍵盤輸入,知道遇到@符號為止,并回顯輸入,同時將大寫字符轉換為小寫,將小寫字母轉換為大寫。
#include<iostream>
#include<cctype>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main(){
char ch;
cout<<"please enter:";
cin>>ch;
while(ch!='@'){
if(islower(ch)){
cout<<ch+32;
};
if(isupper(ch)){
cout<<ch-32;
};
cin>>ch;
};
cout<<endl<<"done";
cin.get();
system("pause");
}這是我寫的代碼,但是輸出的為什么是int型別的值 而不是char型別的
uj5u.com熱心網友回復:
cout<<(char)ch-32;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/124422.html
標籤:基礎類
上一篇:如何用聲卡做個信號發生器?
