摘要: 先判断后转化 原理: 这类题目主要通过ASCII(美国信息交换标准代码)码差值实现,A对应ASCII码十进制数字是65,a对应ASCII码十进制数字是97,即大小写字母之间ASCII码差值为32,想要将大写字母转换为小写字母可以将该字符ASCII码值+32,同理小写字母转换成大写字母只需将该字符AS 阅读全文
posted @ 2019-11-27 20:48 木子欢儿 阅读(8525) 评论(0) 推荐(0) 编辑
摘要: 什么是完数? 如果一个数等于它的因子之和,则称该数为“完数”(或“完全数”)。 例如,6的因子为1、2、3,而 6=1+2+3,因此6是“完数”。 问题分析 根据完数的定义,解决本题的关键是计算出所选取的整数m(m的取值范围不固定)的因子(因子就是所有可以整除这个数的数),将各因子累加到变量sum 阅读全文
posted @ 2019-11-27 18:54 木子欢儿 阅读(4417) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> void fun(int *x,int*y) { int t; if(*x>=*y) { t=*x;*x=*y;*y=t; } } main() { int m,n; printf("请输入2个数字\n"); scanf("%d%d",&m,&n); fun(& 阅读全文
posted @ 2019-11-27 17:10 木子欢儿 阅读(476) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int fun(int x) { int n; for(n=2;n<=x-1;n++) if(x%n==0) break; if(n>=x) return 1; else return 0; } main() { int m; for(m=2;m<1000;m+ 阅读全文
posted @ 2019-11-27 17:02 木子欢儿 阅读(2227) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int fun(int x) { int a, b, c; a = x / 100; b = x % 100 / 10; c = x % 10; if (x == a * a * a + b * b * b + c * c * c) return 1; else 阅读全文
posted @ 2019-11-27 16:55 木子欢儿 阅读(2649) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int max(int x,int y,int z) { if(x>=y) if(x>=z) return x; else return z; else if(y>=z) return y; else return z; } main() { int a,b,c 阅读全文
posted @ 2019-11-27 16:06 木子欢儿 阅读(2960) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int max(int x,int y) { if(x>=y) return x; else return y; } main() { int a,b; printf("请输入2个数字:\n"); scanf("%d%d",&a,&b); printf("最大值 阅读全文
posted @ 2019-11-27 15:59 木子欢儿 阅读(1237) 评论(0) 推荐(0) 编辑