1.
#include
int main()
cout
<<"the sum of numbers between "
<" and "
<" is "
0;}
2.
#include
#include
using
namespace
std;
const
int arsize = 16;
int main()
3.
#include
#include
int main()
return
0;}
4.
#include
int main()
cout
<< i << "年後,cleo的投資價值將超過daphne。"
<< endl;
cout
<< "此時,cleo的投資價值為"
<< cleo[i] << "美元;"
<< "daphne的投資價值為"
<< daphne[i] << "美元。"
<"pause");
return
0;}
5.
#include
#include
int main()
; int sales[12];
int sum = 0;
for (int i = 0; i < 12; i++)
cout
<< "the sales volume of the whole year is "
<< sum << endl;
system("pause");
return
0;}
6.
#include
#include
int main()
; int sales[3][12];
int sum[3];
for (int i = 0; i < 3; i++)
}int sum_all = sum[0] + sum[1] + sum[2];
cout
<< "month";
for (int i = 0; i < 12; i++)
cout
<< "\t"
<< month[i];
for (int i = 0; i < 3; i++)
system("pause");
return
0;}
7.
#include
#include
int main()
; cout
<< "how many cars do you wish to catalog? ";
int num;
cin >> num;
cin.get(); //如果沒有這一行,cin讀取數字後,將回車鍵生成的換行符留在了輸入佇列中,
//後面的getline看到換行符後,將認為是乙個空行 ,並將乙個空字串賦給string物件
car * pcar = new car[num];
for (int i = 0; i < num; i++)
cout
<< "here is your collection:"
<< endl;
for (int i = 0; i < num; i++)
cout
<< pcar[i].year << " "
<< pcar[i].make << endl;
delete pcar;
system("pause");
return
0;}
8.
#include
#include
int main()
cout
<< "you entered a total of "
<< count << " words.\n";
system("pause");
return
0;}
9.
#include
#include
int main()
cout
<< "you entered a total of "
<< count << " words.\n";
system("pause");
return
0;}
10.
#include
int main()
pstar[i] = '*';
cout
<< pstar << "\n";
}delete pstar;
system("pause");
return
0;}
學習筆記 C primer Plus 第5章
1.typedef機制 使用typedef為現有型別建立別名,例如,typedef double real real dead 這兩行的含義表示把real建立為double型別的變數。2.遞增運算 i 和 i 前者 字尾表示使用i的值之後,遞增i。後者 字首表示先遞增i,然後使用i的值。3.沒乙個表...
《Lua程式設計 第4版 》 第5章練習答案
monday sunday sunday 一樣,都指向該錶。a.a.a.a 3,執行的是該錶的索引 a 賦值為3,之後的a.a.a.a將會引發異常,因現a.a 3,而非表。在方括號裡寫索引值 tab for i,j in pairs tab do io.write i,j,n endfunction...
第5章 練習題
5.1 空語句就是乙個單獨的分號 在程式的某個地方語法上需要一條語句但是邏輯上不需要,此時應該使用空語句 5.2用花括號括起來的語句序列,在程式的某個地方語法上需要一條語句,但邏輯上需要多條語句時用 5.3 p5 3.cpp include int main std cout sum of 1 to...