摘要: #include<stdio.h> void main() { long mul, number,k, a,b; printf("It exists following automorphic nmbers small than 100000:\n");for (number=0 ; number< 阅读全文
posted @ 2023-05-17 09:05 痛苦代码源 阅读(16) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> void main() { int a,i,b,n; printf ("There are following friendly--numbers pair smaller than3000:\n"); for(a-1;a<3000;a++) /*穷举3000以内 阅读全文
posted @ 2023-05-16 21:47 痛苦代码源 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 求某一范围内完数的个数。 如果一个数等于它的因子之和,则称该数为“完数”(或“完全数”)。例如,6的因子为1,2,3,而6=1+2+3,因此6是“完数”。 #include<stdio.h> int main() { int i,j,s,n; /*变量i控制选定数范围,j控制除数范围,s记录累加因子 阅读全文
posted @ 2023-05-15 15:43 痛苦代码源 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 问腿:将五元人民币兑换成一元,五角和一角的硬币,共有多少种不同的兑换方式 解答 流程图 程序 #include<stdio.h> int main() { int x,y, z, count=1; printf("可能的兑换方法如下: ln"); for(x=0;x<=50;x+=10)/*x为1元 阅读全文
posted @ 2023-05-14 10:38 痛苦代码源 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 马克思手稿中有一道趣味数学问题:有 30 个人,其中有男人、女人和小孩,他们在同一家饭馆吃饭,总共花了50先令。已知每个男人吃饭需要花3先令,每个女人吃饭需要花2先令,每个小孩吃饭需要花1先令,请编程求出男人、女人和小孩各有几人。 解答 #include<stdio.h> int main() { 阅读全文
posted @ 2023-05-13 22:37 痛苦代码源 阅读(64) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> #include<math.h> int main() { double sum =0; /*定义doub1e型变量sum存放累加和*/ int i; /*使用循环求累加和*/for(i=1;i<-64;i++) sum-sum+pow (2,i-1); prin 阅读全文
posted @ 2023-05-12 22:56 痛苦代码源 阅读(7) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int a[14]; main() { int i,j=1,n; printf(”魔术师手中的牌原始次序是:\n");for(i=1;i<-13;i++) { n=1; /*每次都从一个空盒开始重新计数*/ do if(j>13)j=1;if(a[j]) /*盒子 阅读全文
posted @ 2023-05-11 10:41 痛苦代码源 阅读(8) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int main( int t,a[5]; /*数组a存放分解后的5个数字*/ long int k,i; /*以95860为初值,循环试探*/for(i=95860;;i++) /*从高到低分解当前i中保存的五位数,并顺次存放在数组元素a[01~a[4]中*/f 阅读全文
posted @ 2023-05-10 18:29 痛苦代码源 阅读(9) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int main( int t,a[5]; /*数组a存放分解后的5个数字*/ long int k,i; /*以95860为初值,循环试探*/for(i=95860;;i++) /*从高到低分解当前i中保存的五位数,并顺次存放在数组元素a[01~a[4]中*/f 阅读全文
posted @ 2023-05-09 11:50 痛苦代码源 阅读(8) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int main () int i,j,x, flag-0; /*flag作为控制标志*/ /*从23开始试探,步长为2*/ for(i=23; flag==0;i+=2) for(j=1, x=i;j<=4&&x>=11;j++) if((x+1)%(j+1)= 阅读全文
posted @ 2023-05-08 09:23 痛苦代码源 阅读(5) 评论(0) 推荐(0) 编辑