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

TOP

返回列表