摘要:
int main(){ int i,j,s; for(i=2;i<=1000;i++) { s=0; for(j=1;j<i;j++) { if(i%j==0) { s+=j; } } if(s==i) printf("It's a perfect number:%d.\n",i); }} //编程 阅读全文
posted @ 2018-07-17 16:42
黑大帅gs
阅读(685)
评论(0)
推荐(0)
摘要:
GCC与Dev-Cpp都是支持C99的,但其默认值不是C99标准,为了使用C99语法可以进行如下操作: (1) GCC 编译时加入编译选项 -std=C99 (注意C为大写) (2) Dev-Cpp step1 工具->编译选项->编译器选项卡中,在"编译时加入以下命令"复选框前打钩,里面输入命令 阅读全文
posted @ 2018-07-17 15:13
黑大帅gs
阅读(996)
评论(0)
推荐(0)
摘要:
例如2+22+222+2222+22222(此时共有5个数相加),几个数相加有键盘控制。 方法1: int main(){ int a,n,count=1; long int sn=0,tn=0; printf("please input a and n:\n"); scanf("%d %d",&a 阅读全文
posted @ 2018-07-17 15:11
黑大帅gs
阅读(591)
评论(0)
推荐(0)
摘要:
#include<stdio.h> int main(){ char c; int letters=0,space=0,digit=0,other=0; printf("请输入一行字符:"); while ((c=getchar())!='\n') { if (c >= 'a'&&c <= 'z' 阅读全文
posted @ 2018-07-17 14:16
黑大帅gs
阅读(3647)
评论(0)
推荐(0)
摘要:
#include <stdio.h> void main(){ long n1,n2; int i; n1=n2=1; for(i=1;i<=10;i++) { printf("%12ld %12ld",n1,n2); if(i%2==0) printf("\n"); n1=n1+n2; n2=n1 阅读全文
posted @ 2018-07-17 11:43
黑大帅gs
阅读(85)
评论(0)
推荐(0)