| 查看: 2782 | 回復(fù): 19 | ||||
lirenshun鐵蟲 (初入文壇)
|
[交流]
一步一步學(xué)習(xí)C語言 已有4人參與
|
|
從今天開始一步步學(xué)習(xí)C語言,希望自己能夠一路堅持,貼出剛學(xué)的程序,鼓勵自己,加油。 #include "stdio.h" int main(int argc,char* argv[]) { FILE *s,*d; char ch; if(argc!=3) { printf("please input sourcefile and destfile\ } else { if((s=fopen(argv[1],"r" )==0) { printf("can't open file %s\n",argv[1]) } else { if((d=fopen(argv[2],"w" )==0) {printf("can't open file %s\n",argv fclose(s); } else { while((ch=fgetc(s))!=EOF) fputc(ch,d); fclose(s); fclose(d); } } } } |
自用寶貝 |
木蟲 (著名寫手)

木蟲 (著名寫手)

鐵蟲 (初入文壇)
木蟲 (著名寫手)

木蟲 (著名寫手)

木蟲 (著名寫手)

鐵蟲 (初入文壇)
木蟲 (著名寫手)

鐵蟲 (初入文壇)
|
非常感謝lurencyj提出的寶貴意見,同時希望自己不斷努力,做的更好,嘿嘿,自己加油。今天曬一個關(guān)于求解直角三角形個數(shù)的程序,嘿嘿 #include #include int main(void) { int n; int count=0; int r=0; int p=0; int w=0; int q=0; int rsquare,psquare=0; printf("please input a positive number:" ;scanf("%d",&n); printf("the list of righrt-angled triangles:\n" ;for(r=1;r<=n;r++) { rsquare=r*r; for(p=1;p<=r;p++) { psquare=p*p; w=(int)sqrt(rsquare-psquare); for(q=p;q<=w;q++) { if(rsquare==(psquare+(q*q))) { printf("%d %d %d\n",r,p,q); count++; } } } } if(count==0) { printf("no such right-angled triangles!\n" ;} else { printf("there are %d right-angled triangled in total!\n",count); } return 0; } |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 286分調(diào)劑 +10 | Faune 2026-03-30 | 11/550 |
|
|---|---|---|---|---|
|
[考研] 0703一志愿9,初試成績:338,四六級已過,有科研經(jīng)歷,求調(diào)劑! +7 | Zuhui0306 2026-03-25 | 7/350 |
|
|
[考研] 0703本科鄭州大學(xué)求調(diào)劑 +7 | nhj_ 2026-03-25 | 7/350 |
|
|
[考研] 材料與化工272求調(diào)劑 +21 | 阿斯蒂芬2004 2026-03-28 | 21/1050 |
|
|
[考研] 求調(diào)劑,一志愿 南京航空航天大學(xué)大學(xué) ,080500材料科學(xué)與工程學(xué)碩 +6 | @taotao 2026-03-26 | 7/350 |
|
|
[考研] 282求調(diào)劑 +4 | wcq131415 2026-03-24 | 4/200 |
|
|
[考研] 375求調(diào)劑 +6 | 雨夏整夜 2026-03-29 | 6/300 |
|
|
[考研] 299求調(diào)劑 +10 | 15188958825 2026-03-25 | 10/500 |
|
|
[考研] 070305高分子化學(xué)與物理 304分求調(diào)劑 +12 | c297914 2026-03-28 | 12/600 |
|
|
[考研] 085600,專業(yè)課化工原理,321分求調(diào)劑 +5 | 大饞小子 2026-03-28 | 5/250 |
|
|
[考研] 081200-11408-276學(xué)碩求調(diào)劑 +6 | 崔wj 2026-03-26 | 6/300 |
|
|
[考研] 312,生物學(xué)求調(diào)劑 +3 | 小譯同學(xué)abc 2026-03-28 | 3/150 |
|
|
[考研] 394求調(diào)劑 +3 | 好事多磨靜候佳?/a> 2026-03-26 | 5/250 |
|
|
[考研] 一志愿南京航空航天大學(xué)材料學(xué)碩求調(diào)劑 +3 | @taotao 2026-03-28 | 3/150 |
|
|
[考研] 272求調(diào)劑 +7 | 腳滑的守法公民 2026-03-27 | 7/350 |
|
|
[考研] 315調(diào)劑 +4 | 0860求調(diào)劑 2026-03-26 | 5/250 |
|
|
[考研] 324求調(diào)劑 +5 | hanamiko 2026-03-26 | 5/250 |
|
|
[考研] 調(diào)劑 +4 | 柚柚yoyo 2026-03-26 | 4/200 |
|
|
[考研] 中國科學(xué)院深圳先進技術(shù)研究院-光纖傳感課題組招生-中國科學(xué)院大學(xué)、深圳理工大學(xué)聯(lián)培 +5 | YangTyu1 2026-03-26 | 5/250 |
|
|
[考研] 340求調(diào)劑 +5 | 話梅糖111 2026-03-24 | 5/250 |
|