二进位也可以很有趣
Programming Concept 蔡文能 tsaiwn@.tw 交通大學資訊工程學系 程式 隨便寫 隨便對? 蔡文能 tsaiwn@.tw 交通大學資訊工程學系 印出根號 2 /* 寫個程式印出根號2 */ #includestdio.h double sqrt(double); // #includemath.h int main( ) { printf( sqrt 根號 2 =%f\n , sqrt(2.0) ); // C++ 式的註解 comment printf(Bye bye!\n); return 0; } 印出根號 3 /* 寫個程式印出根號3 */ #includestdio.h double sqrt(double); // #includemath.h int main( ) { printf( sqrt 根號 3 =%f\n , sqrt(3.0) ); // C++ 式的註解 comment printf(Bye bye!\n); return 0; } 印出根號 x /* 寫個程式印出根號 x */ #include stdio.h #includemath.h double y; int main( ) { printf( Give me x : ); scanf(%lf , y); printf(Sqrt(%f)=%f\n, y, sqrt(y) ); return 0; } 程式 隨便寫 求 x 的平方根 蔡文能 tsaiwn@.tw 交通大學資訊工程學系 p3.c – 練習 while loop #include stdio.h #include math.h int main() /* This program can find square root of any number that =0 and will stop when you enter a value that 0 阿版權是蔡文能的, 歡迎拷貝分享初學者! */ { float onevar; /* 變數名稱隨便我取的啦 */ double ans; /* 用來放答案 */ printf(Find square root of X. Negative value will cease the program\n); printf(X=? ); /* 還是問X=? 比較簡潔有力, 不用說onevar */ scanf(%f, onevar); while(onevar =0 ) { /*只要onevar大於或等於零我們就一直重複做{...} */ ans=sqrt(onevar); /*其實sqrt的參數也應該為double 型別*/ printf( SQRT(%f)=%f\n, onevar, ans); printf(X=? ); scanf(%f, onevar); } /* while(onevar */ return 0; } 程式 隨便寫 求 x 的平方根 p4.c – 練習 想 Algorithm(1/2) /* This program can find square root of any number that =0 and will stop when you enter a value that 0 */ /* This version is trying to show you that we can write our function/procedure to solve the problem, though the mysqrt() is actually calling the system standard function. We will rewrite the mysqrt() in next version. *****************************/ void hello(void); /*我會用到一個沒參數的函數叫hello() */ double mysqrt(double); /*也會叫用一個叫mysqrt()的函數,參數是一個double數 */ #include math.h /* sqrt()是在math.h內宣告的 */ int main()
您可能关注的文档
- 中国建筑的特征.ppt
- 中国常见鱼类检索表.doc
- 中国居民膳食指南2015.ppt.ppt
- 中国散藏吐鲁番文献知见录-北京大学中国古代史研究中心.doc
- 中国医科大学.ppt-中华人民共和国教育部.ppt
- 中国机械工业科学技术奖励工作办公室-科技工作部.doc
- 中国水产学会海水养殖分会-中国水产科学研究院南海水产研究所.doc
- 中国汽车能效标识方案研究-EnergyFoundationChina.ppt
- 中国十大名楼.ppt
- 中国海洋渔业发展研究.doc
- 河北盐山中学等校2025-2026学年上学期高三一模化学试卷(含解析).docx
- 河北正定中学2025-2026学年高一上学期期末考试物理试卷(含解析).docx
- 河北张家口市怀安县2025-2026学年第一学期期末教学综合评价八年级地理试卷(含解析).docx
- 河南安阳市殷都区2025-2026学年第一学期期末教学质量检测七年级地理试卷(含解析).docx
- 河南安阳市滑县2025一2026学年第一学期期末学业质量监测八年级地理试题(含解析).docx
- 河南安阳市林州市2025-2026学年上学期期末考试高一政治试题(含解析).docx
- 河南焦作市武陟县第一中学2025-2026学年高一上学期1月月考语文试卷(含解析).docx
- 河南济源市2025-2026学年上学期期末学业质量调研七年级历史试卷(含解析).docx
- PICC导管并发症的紧急处理与护理.pptx
- 河南鹤壁市2025-2026学年高二上学期期末考试生物试题(含解析).docx
原创力文档

文档评论(0)