为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > 由键盘输入正整数n

由键盘输入正整数n

2018-08-15 3页 doc 14KB 9阅读

用户头像

is_574951

暂无简介

举报
由键盘输入正整数n由键盘输入正整数n 班級 座號 姓名 1. 由鍵盤輸入正整數n,求n的所有因數(包含n本身)和因數3. 寫一程式,顯示如右 1*1= 1 2*1= 2 3*1= 3 1*2= 2 2*2= 4 3*2= 6 總和(若 n等於其所有因數總和) 10% 結果 10% #include #include 請按任意鍵繼續 . . . 輸入正整數: 24 #include #include 24的因數有 1 2 3 4 6 8 12 24 int main(void) int main(void) 因數和=60 { { 請...
由键盘输入正整数n
由键盘输入正整数n 班級 座號 姓名 1. 由鍵盤輸入正整數n,求n的所有因數(包含n本身)和因數3. 寫一程式,顯示如右 1*1= 1 2*1= 2 3*1= 3 1*2= 2 2*2= 4 3*2= 6 總和(若 n等於其所有因數總和) 10% 結果 10% #include #include 請按任意鍵繼續 . . . 輸入正整數: 24 #include #include 24的因數有 1 2 3 4 6 8 12 24 int main(void) int main(void) 因數和=60 { { 請按任意鍵繼續 . . . system("pause"); return 0; } system("pause"); return 0; 4. 寫一程式,印出1~20中, 1 5 7 11 13 17 19 } 所有不被2或3整除的數字,請按任意鍵繼續 . . . 顯示如右結果 10% 2. 試撰寫一非遞迴函數 int cube(int x,int y),可 #include 以傳回x 的 y 次方。 10% #include #include int main(void) #include { int main(void) { int x,y; do { printf("Input two integer:"); scanf(“%d %d”,&x ,&y); } while (x<=0||y<=0); printf(“cube(%d,%d)=%d\n”, ); system("pause"); return 0; } system("pause"); return 0; } 2 5. 試定義巨集函數f(x)=2x+1,並印出f(5)的值。10% #include #include int main(void) { system("pause"); return 0; } 班級 座號 姓名 #include 6. 定義f(n)=1*2+2*3+3*4+…+(n-1)*n, #include 寫出 f(n)的遞迴式 (n>=1) 5% int main(void) { f(n)= 由上的遞迴式,寫出f(n)求的程式 10% #include Input the number n: 4 #include Answer=20 int main(void) 請按任意鍵繼續 . . . { system("pause"); return 0; } 8. 使用 switch寫一程式,由 輸入運算式: 10+20 鍵盤輸入一運算式x+y或 system("pause"); 10+20=30 x-y或x*y或x/y,並印出運 return 0; 算結果,顯示如右結果 10% 請按任意鍵繼續 . . . } #include int f(int n) #include { int main(void) { } 7. 分別用for、while各寫一程式,由鍵盤輸入整數值n(須考 5-22 慮n是大於等於0或小於0,例如2=32、2=1/2=0.25), n寫一程式求 2 。 20% #include #include int main(void) { system("pause"); return 0; } 9. Ackerman’s function A(m,n)的遞迴式定義如下: 5% n,1,ifm,0, , Ack(m-1,1)Ack(m,n)= ,ifn,0, ,,otherwiseAck(m-1,Ack(m,n-1)), 求 ack(1,2)= system("pause"); return 0; }
/
本文档为【由键盘输入正整数n】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索