2023年5月27日

32.最大公约数

摘要: #include <stdio.h> int main(){ int m = 0; int n = 0; int tmp = 0; printf("请输入两个整数: "); scanf("%d %d", &m, &n); while (tmp = m % n) { m = n; n = tmp; } 阅读全文

posted @ 2023-05-27 00:06 HA_wind 阅读(15) 评论(0) 推荐(0)

2023年5月25日

31.不重复的三位数

摘要: /*题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列*/ #include<stdio.h>int main(){ int i,j,k; int count; // 阅读全文

posted @ 2023-05-25 23:58 HA_wind 阅读(41) 评论(0) 推荐(0)

2023年5月24日

30.勾股数

摘要: #include<stdio.h>#include<math.h>int main(){ int a, b, c, count=0; printf("100以内的勾股数有:\n"); printf(" a b c a b c a b c a b c\n"); /*求100以内勾股数*/ for(a= 阅读全文

posted @ 2023-05-24 21:20 HA_wind 阅读(24) 评论(0) 推荐(0)

2023年5月23日

29.黑洞数

摘要: #include<stdio.h>int main(){ int n,a,b,c,t,y,cnt=0; scanf("%d",&n); if(n==495) printf("1: 954 - 459 = 495\n");else{ while(n!=495) { cnt++; a=n%10;//得出 阅读全文

posted @ 2023-05-23 23:16 HA_wind 阅读(24) 评论(0) 推荐(0)

2023年5月22日

28.高次方数的尾数

摘要: #include <stdio.h>int main(){int i, x, y, last=1; /*变量last保存求得的x的y次方的部分积的后三位*/printf("请输入x 和 y:\n");scanf("%d %d", &x, &y);for(i=1; i<=y; i++) /*x自乘的次 阅读全文

posted @ 2023-05-22 23:41 HA_wind 阅读(17) 评论(0) 推荐(0)

2023年5月21日

27.阿姆斯特朗数

摘要: #include <stdio.h>int main(){ int i,m,k,n; for(n=1; n<=1000; ++n) //开始循环 { k=n; //初始化 m=0; while(k>0) //开始分解,求各个位数阶乘之和。 { i=k%10; m+=i*i*i; k=k/10; } 阅读全文

posted @ 2023-05-21 23:10 HA_wind 阅读(14) 评论(0) 推荐(0)

2023年5月20日

26水仙花数

摘要: #include <stdio.h> #define INTEGER_MAXIMUM 999 //数字范围,最大值#define INTEGER_MINIMUM 100 //最小值 int if_narcissistic_number(int num); int main(){ int i = 0; 阅读全文

posted @ 2023-05-20 22:17 HA_wind 阅读(18) 评论(0) 推荐(0)

2023年5月19日

25.回文数

摘要: 代码实现: #include<bits/stdc++.h>using namespace std;int main(){ int a,b,i,k,g=0; scanf("%d%d",&a,&b); for(i=a;i<=b;i++) { g=0; k=i; while(k>0) { g=g*10+k 阅读全文

posted @ 2023-05-19 23:16 HA_wind 阅读(24) 评论(0) 推荐(0)

2023年5月17日

24.自守数

摘要: #include<cstdio>using namespace std;bool t(int n){ int s=n*n,x=1; while(x<n) x=x*10; return s%x==n;}long long a,b;int main(){ scanf("%lld%lld",&a,&b); 阅读全文

posted @ 2023-05-17 21:59 HA_wind 阅读(20) 评论(0) 推荐(0)

2023年5月16日

23.亲密数

摘要: 代码实现: #include<stdio.h>void main(){ int a,i,b,n; printf("There are following friendly-numbers pair smaller than 3000:\n"); for(a=1;a<3000;a++){ for(b= 阅读全文

posted @ 2023-05-16 22:21 HA_wind 阅读(21) 评论(0) 推荐(0)

导航