1.試著逐行瞭解下面的程式碼,並在每一行敘述後面加上註解,然後編譯並執行它。 01 // hw2_1, C++程式的練習 02 #include 03 #include 04 using namespace std; 05 int main(void) 06 { 07 int num; 08 num=6; 09 cout 10 cout 11 system("pause"); 12 return 0; 13 } 2.試寫一程式列印字串內容 "There is no rose without a thorn."。撰寫程式的同時,也請您為每一行敘述加上註解。 3.請試著練習將n1、n2宣告成整數型態變數,宣告完成後,再將n1設值為6,n2設值為8,最後再將n1、n2的值及n1+n2的值印出。請為每一行敘述加上註解。 4.試找出下列程式何處有誤,並加以改正。 01 // hw2_13, 請找出此程式何處有誤 02 #include 03 #include 04 int main(void) 05 { 06 int num=2 07 cout 08 } 09 system("pause"); 10 return 0; 11 } 5.下面的程式碼是一個簡單的C++程式,其程式的編排方式並不易於閱讀。請重新編排它來提高程式的可讀性: 01 // hw2_15, 沒有編排的程式 02 #include 03 #include 04 using namespace std;int main(void){int a,b;a=8;b=10; 05 cout 06 system("pause");return 0;}
目前沒有資料
目前沒有資料
馬上按讚 加入 Yahoo! 奇摩 知識+ 粉絲團
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.
You are receiving this email because you subscribed to this feed at blogtrottr.com.