| 查看: 2783 | 回復: 19 | ||||
lirenshun鐵蟲 (初入文壇)
|
[交流]
一步一步學習C語言 已有4人參與
|
|
從今天開始一步步學習C語言,希望自己能夠一路堅持,貼出剛學的程序,鼓勵自己,加油。 #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提出的寶貴意見,同時希望自己不斷努力,做的更好,嘿嘿,自己加油。今天曬一個關于求解直角三角形個數(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ā)表 | |
|---|---|---|---|---|
|
[考研] 085601一志愿西北工業(yè)大學初試346 +4 | 085601初試346 2026-03-30 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 070300化學279求調(diào)劑 +5 | 哈哈哈^_^ 2026-03-31 | 7/350 |
|
|
[考研] 370求調(diào)劑 +3 | 080700調(diào)劑 2026-03-30 | 3/150 |
|
|
[考研] 289求調(diào)劑 +16 | 新時代材料 2026-03-27 | 16/800 |
|
|
[考研] 322求調(diào)劑 +10 | 宋明欣 2026-03-27 | 10/500 |
|
|
[考研] 283求調(diào)劑(080500) +14 | A child 2026-03-27 | 14/700 |
|
|
[考研] 085602 化學工程專碩 340分求調(diào)劑 +4 | qianbai11 2026-03-29 | 4/200 |
|
|
[考研] 375求調(diào)劑 +6 | 雨夏整夜 2026-03-29 | 6/300 |
|
|
[考研] 356求調(diào)劑 +4 | gysy?s?a 2026-03-28 | 4/200 |
|
|
[考研] 2026年華南師范大學歡迎化學,化工,生物,生醫(yī)工等專業(yè)優(yōu)秀學子加入! +3 | llss0711 2026-03-28 | 6/300 |
|
|
[考研] 調(diào)劑考研 +3 | 王杰一 2026-03-29 | 3/150 |
|
|
[考研] 330分求調(diào)劑 +5 | qzenlc 2026-03-29 | 5/250 |
|
|
[考研] 0703化學調(diào)劑,求導師收 +9 | 天天好運來上岸?/a> 2026-03-24 | 10/500 |
|
|
[考研] 308求調(diào)劑 +7 | 墨墨漠 2026-03-27 | 7/350 |
|
|
[考研] 352分 化工與材料 +5 | 海納百川Ly 2026-03-27 | 5/250 |
|
|
[考研] 330一志愿中國海洋大學 化學工程 085602 有讀博意愿 求調(diào)劑 +3 | wywy.. 2026-03-27 | 4/200 |
|
|
[考博] 26申博 +3 | 加油沖! 2026-03-26 | 3/150 |
|
|
[考研] 復試調(diào)劑,一志愿南農(nóng)083200食品科學與工程 +5 | XQTJZ 2026-03-26 | 5/250 |
|
|
[考研] 302求調(diào)劑 +4 | 錦衣衛(wèi)藤椒 2026-03-25 | 4/200 |
|
|
[考研] 0854人工智能方向招收調(diào)劑 +4 | 章小魚567 2026-03-24 | 4/200 |
|