- 博客(23)
- 收藏
- 关注
原创 5.8
这里写代码片#include <stdio.h> #include <stdlib.h> int main() { char ch; printf("请输入一个字符\n"); scanf("%c",&ch); if(ch>=48&&ch<=57){ printf("ch为数字字符\n"); } else
2017-12-31 20:55:20 164
原创 7.9
这里写代码片#include<stdio.h>int main(){ int i,s=-0,a=0; for(i=0;i<5;i++) { s=10+a; a=a+2; } printf("第五个人%d岁",s); retur` 0;}
2017-12-31 20:51:04 156
原创 6.3
这里写代码片#include<stdio.h>#include<stdlib.h>int main(){ int x, find=0; for(x=1;!find;x++) {if(x%2==1 && x%3==2 && x%5==4 && x%6==5 &&x%7==0){printf("x=%d\n",x);find=1;}}return 0;}
2017-12-31 20:45:52 131
原创 鸡兔同笼
这里写代码片#include <stdio.h>#include <stdlib.h>int main(){ int i; for(i=2;i<=98;i++) { if(i*2+(98-i)*4==386) break; } printf("鸡=%d\n兔=%d",i,(98-i)); return 0;}
2017-12-31 20:41:02 275
原创 2用辗转相除法计算两个整数的最大公约数
这里写代码片#include<stdio.h>int main(){ int a,b,c; printf("请输入两个整数:"); scanf("%d%d",&a,&b); if(a<b) { c=a; a=b; b=c; } while(c=a%b) { a=b;
2017-12-31 20:32:50 4929
原创 比较两个数的大小
这里写代码片#include<stdio.h>int max(int a,int b){ return a>b?a:b;}int main(){ int a,b; printf("请输入两个整数:"); scanf("%d%d",&a,&b); printf("max=%d\n",ma(a,b));}
2017-12-31 20:28:08 1011
原创 1*2*n的值
这里写代码片#include<stdio.h>main(){ int i,n,cj; printf("Input n:"); scanf("%d",&n); cj=1; for(i=1;i<=n;i++){ cj=cj*i;} printf("cj=%d \n",cj);} 心得:仿照加减写乘法 知识
2017-12-31 20:08:16 400
原创 1+3+++2*(n+1)
这里写代码片#include<stdio.h>main(){ int i,n,sum; printf("Input n="); scanf("%d",&n); sum=0; for(i=1;i<=2*n+1;i=i+2) { sum=sum+i;}printf("sum=%d\n",sum);}心得:注意领会i=i+2的含义
2017-12-31 20:02:25 170
原创 s三角形
这里写代码片#include<stdio.h>#include<math.h>main(){ float a,b,c,s,area; printf("Input a,b,c:"); scanf("%f %f %f",&a,&b,&c); s=(a+b+c)/2; area=(float)sqrt(s*(s-a)*(s-b)*(s-c)); pri
2017-12-31 19:54:43 726
原创 字母转化
#include <stdio.h>#include <stdlib.h>int main(){ char ch; printf("Input 大写字母:"); ch=getchar(); ch=ch+32; printf("转化的小写字母为:"); putchar(ch); return 0;}
2017-12-31 16:00:43 181
原创 计算1*2*,,,,*5的积
#include<stdio.h>int main(){ double s; int i; s=1; for(i=1;i<=5;i++) s*=i; printf("结果:%lf\n",s); return 0;}
2017-12-13 19:58:36 335
原创 3
水仙花#include<stdio.h>int main(){int x;int a,b,c ;scanf ("%d",&x);c=x/100;a=x%10;//求x的个位b=(x-c*100)/10;//求十位if(a*a*a+b*b*b+c*c*c==x)printf("yes\n");elseprintf("no\n");return 0;}
2017-12-13 19:51:40 110
原创 6.3
#include <stdio.h>int main(){ int x=1,find=0; while (1) { if(x>200) continue ; x++; if( x%2==1&&x%3==2&&x%5==4&&x%6==5&&x%7==0) { printf("x=%d\n",x);
2017-11-13 17:08:31 134
原创 从键盘任意输入一个年号,并判断它是否是润年
#include <stdio.h>#include <stdlib.h>int main(){ int year,flag; printf("Enter year:"); scanf ("%d",&year); if(year%4==0&&year%100!=0) flag=1; else flag=0; if (
2017-11-11 17:51:15 10921
原创 输入任意一个整数,编程判断这个数的奇偶性。
这里写代码片#include <stdio.h>#include <stdlib.h>int main(){ while (1) { int i; scanf("%d",&i); if(i<=0) printf ("结果错误!\n"); for(;i>0;) { if(i%2==0) pri
2017-11-05 23:04:33 6845
原创 分析并写出下列程序的运行结果
这里写代码片这里写代码片#include <stdio.h>#include <stdlib.h>int main(){ int i,j,k; char space=' ' ; for (i=1;i<=4;i++) { for(j=1;j<=i;j++) { printf ("%c",space ); }
2017-11-05 00:29:06 2518
原创 a,b赋值转换
这里写代码片#include <stdio.h>#include <stdlib.h>int main(){ int a=1,b=2; a=a+b; b=a-b; a=a-b; printf ("a=%d\tb=%d",a,b); return 0;}
2017-11-04 18:01:25 1523
原创 九九乘法表
这里写代码片#include <stdlib.h>int main(){ int i,j; for (i=1;i<=9;i++) { for (j=1;j<=i;j++) { printf ("%d*%d=d\t",j,i,i*j); } printf ("\n"); }}
2017-11-01 11:55:08 131
原创 求最大公约数
这里写代码片#include <stdio.h>int main(){ int a,b,r; scanf("%d%d",&a,&b); while(b!=0) { r=a%b; a=b; b=r; } printf("%d\n",a); return 0;}心得体会:
2017-11-01 11:44:05 172 1
原创 作业
p8习题 (1) 总结图1-2中列出的10种编程语言各自的特点和主要应用领域。 答:根据图表可以看出当今编程语言中C语言和Java语言最受欢迎,使用人数也是最多的,其他几门语言相对使用的人数较少。除C语言以外的9种语言中,有6种都直接使用,间接使用或部分借鉴了C语言的语法。 C 操作系统、嵌入式、自动化控制C++ 游戏、游戏服务器框架及游戏引擎、一些GUI框架、科研、编译器、图形学C# Win
2017-10-22 15:21:26 221
原创 成绩系统
这里写代码片#include <stdio.h>#include <stdlib.h>int main(){ int i;while(1){ scanf ("%d",&i); if(i>100||i<0) printf("结果错误!!\n"); else if(i>=90) printf("A"); else if(i>=80) printf
2017-10-20 21:02:26 197
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人