譚浩強C 第三章(2)

2021-10-25 11:26:12 字數 1075 閱讀 4332

19、水仙花數(三位數,各位數字的立方和等於該數字本身)

20、1000以內的完數(數等於因數和)

#include

#include

using namespace std;

intmain()

}if(i==s)

} cout<

return0;

}

21、分數列前20項和(2/1+3/2+5/3+8/5+…)
#include

using namespace std;

intmain()

cout<

return0;

}

22、猴子吃桃
#include

using namespace std;

intf

(int n)

intmain()

23、迭代法求平方根
#include

using namespace std;

intmain()

cout<

" "<

return0;

}

24、輸出圖案
#include

using namespace std;

voidf(

int n)

cout<

}int

main()

25、桌球比賽名單
#include

using namespace std;

intmain()

}}}}

}return0;

}

譚浩強C 第三章(1)

1 表示式 表示式語句 表示式後面加 即可成為表示式語句。賦值表示式加分號成為賦值語句,大多數的語句是表示式語句 包括函式呼叫語句 表示式是程式的基本要素,它可以組成關係表示式,邏輯表示式等多種表示式以完成需要的功能。見課本p45 2 編寫程式求圓周長 面積,圓柱體表面積 體積,圓球表面積 體積 i...

C語言第三章

main.c project1 created by sihan guo on 2019 06 13.include int main int argc,const char ar else 迴圈結構 當型 int icount 5 while icount 0 直到型迴圈結構 這個迴圈結構至少執行...

學習C 第三章

經過網上發現和自己總結,最終把 改為 include using namespace std int main 我的同學用的是另外乙個編譯器,而我用的是vs,他根據原文打沒有出現報錯,關於隱式型別轉換貌似很少用到,這其實類似於隱式型別轉換不太支援然後轉化為指標了。具體解決方式就是 把 char a ...