本站電子書

您可以在這些電子書店找到本站電子書: Google Play 圖書iBooks StoreHyReadReadmooPubu
===>>>本站推出學習遊戲意見調查<<<===《如何自學程式設計》入選 Google Play 台灣地區2016年度最佳書籍

C++ 入門指南 V2.00 - 單元 6 範例及練習程式碼



exercise0601.cpp


#include <iostream>
 
using namespace std;
 
int main(void) {
   int a = 2;
   int b = 8;
    
   cout << "a + b = " << a + b << endl;
   cout << "a - b = " << a - b << endl;
   cout << "a * b = " << a * b << endl;
   cout << "a / b = " << a / b << endl;
   cout << "a % b = " << a % b << endl;
    
   return 0;
}
 
/* 檔名: exercise0601.cpp 
   作者: Kaiching Chang 
   時間: 2014-5 */

exercise0602.cpp


#include <iostream>
 
using namespace std;
 
int main(void) {
   int a;
   int b;
    
   cin >> a;
   cin >> b;
    
   cout << "a + b = " << a + b << endl;
   cout << "a - b = " << a - b << endl;
   cout << "a * b = " << a * b << endl;
   cout << "a / b = " << a / b << endl;
   cout << "a % b = " << a % b << endl;
    
   return 0;
}
 
/* 檔名: exercise0602.cpp 
   作者: Kaiching Chang 
   時間: 2014-5 */

exercise0603.cpp


#include <iostream>
 
using namespace std;
 
int main(void) {
   double a;
   double b;
    
   cin >> a;
   cin >> b;
    
   cout << "a + b = " << a + b << endl;
   cout << "a - b = " << a - b << endl;
   cout << "a * b = " << a * b << endl;
   cout << "a / b = " << a / b << endl;
    
   return 0;
}
 
/* 檔名: exercise0603.cpp 
   作者: Kaiching Chang 
   時間: 2014-5 */

exercise0604.cpp


#include <iostream>
 
using namespace std;
 
int main(void) {
   int a = 1;
    
   cout << "++a = " << ++a << endl;
   cout << "++a = " << ++a << endl;
   cout << "++a = " << ++a << endl;
   cout << "++a = " << ++a << endl;
   cout << "++a = " << ++a << endl;
   cout << "++a = " << ++a << endl;
   cout << "++a = " << ++a << endl;
    
   return 0;
}
 
/* 檔名: exercise0604.cpp 
   作者: Kaiching Chang 
   時間: 2014-5 */

exercise0605.cpp


#include <iostream>
 
using namespace std;
 
int main(void) {
    string a("*");
    
    cout << a << endl;
    cout << a + a << endl;

    return 0;
}
 
/* 檔名: exercise0605.cpp 
   作者: Kaiching Chang 
   時間: 2014-5 */

exercise0606.cpp


#include <iostream>
 
using namespace std;
 
int main(void) {
   int a = 1;
   int b = 2;
    
   cout << (a > b ? "a is bigger" : "b is bigger") << endl;

   return 0;
}
 
/* 檔名: exercise0606.cpp 
   作者: Kaiching Chang 
   時間: 2014-5 */

exercise0607.cpp


#include <iostream>
 
using namespace std;
 
int main(void) {
   int a;
   int b;
    
   cin >> a;
   cin >> b;
    
   cout << (a > b ? "a is bigger" : "b is bigger") << endl;

   return 0;
}
 
/* 檔名: exercise0606.cpp 
   作者: Kaiching Chang 
   時間: 2014-5 */

the end

沒有留言: