![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔记
qq_51362216
这个作者很懒,什么都没留下…
展开
-
2021-06-06
求两数的最大公因数 法一:更相减损法。 #include<stdio.h> #include<math.h> main() { int a,b,t; printf("请输入两个数:"); scanf("%d%d",&a,&b); for(;;) { if(a>b) { t=a-b; a=b; b=t; }原创 2021-06-06 21:28:28 · 47 阅读 · 0 评论 -
2021-06-05
例题2.1 求5的阶乘 #include<stdio.h> main() { int i,t=1; for(i=1;i<=5;i++) t*=i; printf("5的阶乘为:%d",t); }原创 2021-06-05 14:25:42 · 34 阅读 · 0 评论 -
2021-06-05
课后题! 编写一个c程序,输出a,b,c中的最大值。 #include<stdio.h> main() { int a,b,c,max; printf("请输入a,b,c的值:"); scanf("%d%d%d",&a,&b,&c); max=a; if(b>max) max=b; if(c>max) max=c; printf("最大的数为:%d",max); }原创 2021-06-05 13:44:14 · 55 阅读 · 0 评论 -
2021-01-05
用c语言编写代码计算sum=a+aa+aaa+…+a…a(n个a) (其中a是一个数)以下我用for循环和while循环两种方法编写(仅供参考) (1)for循环 #include<stdio.h> main() { int a,n,i; int t=0,sum=0; printf("请输入a和n:"); scanf("%d%d",&a,&n); for(i=1;i<=n;i++) { t=t*10+a;原创 2021-01-05 23:13:59 · 61 阅读 · 0 评论