本帖最後由 蔡庭豪 於 2016-8-13 11:22 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- void ifschoose(int choose){
- int i;
- float f;
- char c[5];
- if(choose==1){
- cin>>i;
- cout<<"對應到的記憶體數為"<<sizeof(i)<<endl;
- }
- else if(choose==2){
- for(int x=0;x<5;x++){
- cout<<"請輸入第"<<x+1<<"中文字"<<endl;
- cin>>c[x];
- }
- cout<<"對應到的記憶體數為"<<sizeof(c)*4<<endl;
- }
- else if(choose==3){
- cin>>f;
- cout<<"對應到的記憶體數為"<<sizeof(f)<<endl;
- }
-
- }
- int main(){
- int choose;
- cout<<"請問你想輸入什麼 (1)數字(2)中文字(3)小數:"<<endl;
- cin>>choose;
- ifschoose(choose);
-
- system("pause");
- return 0;
- }
- }
複製代碼 |