返回列表 發帖
本帖最後由 蔡庭豪 於 2016-8-13 11:22 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. void ifschoose(int choose){
  5.         int i;
  6.     float f;
  7.     char c[5];
  8.         if(choose==1){
  9.         cin>>i;         
  10.         cout<<"對應到的記憶體數為"<<sizeof(i)<<endl;
  11.         }
  12.         else if(choose==2){
  13.         for(int x=0;x<5;x++){
  14.         cout<<"請輸入第"<<x+1<<"中文字"<<endl;
  15.         cin>>c[x];         
  16.     }
  17.         cout<<"對應到的記憶體數為"<<sizeof(c)*4<<endl;
  18.         }
  19.     else if(choose==3){
  20.         cin>>f;
  21.         cout<<"對應到的記憶體數為"<<sizeof(f)<<endl;
  22.         }
  23.        
  24. }
  25. int main(){
  26.     int choose;
  27.     cout<<"請問你想輸入什麼 (1)數字(2)中文字(3)小數:"<<endl;
  28.     cin>>choose;
  29.     ifschoose(choose);
  30.    
  31. system("pause");
  32.     return 0;
  33. }
  34. }
複製代碼

TOP

返回列表