![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c语言程序设计
?? 38381517109
这个作者很懒,什么都没留下…
展开
-
5.8字符
#include <stdio.h>#include <stdlib.h>int main(){ char ch; printf("请输入一个字符ch:"); scanf("%c",&ch); if(ch>=65&&ch<=90) { printf("该字符是大写字母\n"); printf("ch=%c\n",ch);原创 2017-11-07 16:38:52 · 120 阅读 · 0 评论 -
6.11
#include <stdio.h>#include <stdlib.h>int main(){ int i=0,n; int sum=0,disc=1; printf("Input n:"); scanf("%d",&n); while(sum<n) { i++; disc*=i; sum+=dis原创 2017-11-18 18:08:52 · 215 阅读 · 0 评论 -
一元二次方程1
#include <stdio.h>#include <stdlib.h>int main(){ int a,b,c,disc; float x1,x2; printf("Input a,b,c"); scanf("%d%d%d",&a,&b,&c); disc=b*b-4*a*c; if(disc>0) { x1=-b+sqrt(disc原创 2017-11-03 21:02:21 · 141 阅读 · 0 评论 -
5.2
#include <stdio.h>#include <stdlib.h>int main(){ int a; printf("Input a\n",a); scanf("%d",&a); if(a%2==0) { printf("偶数"); } else printf("奇数"); return 0原创 2017-11-03 15:15:01 · 125 阅读 · 0 评论 -
5.1
#include <stdio.h>main(){ int a,disc; scanf("%d",&a); disc=a*a; if(disc>=0) { a=sqrt(disc); printf("输出a绝对值为:a=%d\n",a); }}知识点:if语句原创 2017-11-03 14:39:50 · 146 阅读 · 0 评论 -
九九乘法表
#include <stdio.h>main(){ int i,j; for(i=1;i<10;i++) { for(j=1;j<=i;j++) { printf("%d*%d=%d\t",j,i,i*j); } printf("\n"); } return 0;}原创 2017-11-03 14:15:27 · 114 阅读 · 0 评论 -
4.3
(1) 要使下面程序在屏幕上显示1,2,34,则从键盘输入的数据格式应为#include <stdio.h>main(){ char a,b; int c; scanf("%c%c%d",&a,&b,&c); printf("%c,%c,%d\n",a,b,c); return 0;} (2) 在与上面程序的键盘输入相同的情况下,若将程序中的第7条语句修原创 2017-11-03 13:54:37 · 486 阅读 · 0 评论 -
4.2
分析下面程序,请指出错误的原因和程序错在哪里,并改正错误#include <stdio.h>main(){ long a,b; float x,y; scanf("%d,%d\n",a,b); scanf("%5.2f,5.2f\n",x,y); printf("a=%d,b=%d\n",a,b); printf("x=%d,y=%d\n",x,原创 2017-11-03 13:09:36 · 308 阅读 · 0 评论 -
5.3
#include <stdio.h>#include <stdlib.h>int main(){ float a,b,c,s,area; printf("Input a,b,c:"); scanf("%f%f%f",&a,&b,&c); if(a+b>c) { s=(a+b+c)/2; area=(float)sqrt(s*原创 2017-11-04 16:22:10 · 118 阅读 · 0 评论 -
6.12
#include <stdio.h>#include <stdlib.h>int main(){ int n; int sum=0; for(;;) { scanf("%d",&n); if(n<=0) break; sum+=n; } printf("%d\n",sum); return原创 2017-11-18 22:02:11 · 176 阅读 · 0 评论 -
分数段
#include <stdio.h>#include <stdlib.h>int main(){ int i; while(1) { scanf("%d",&i); if(i>100||i<0) { printf("错误! !"); } if(i>=90) printf("A"); else if(i>=8原创 2017-11-09 22:47:14 · 134 阅读 · 0 评论 -
1!+2!+3!+、、、+n!的值
#include <stdio.h>#include <stdlib.h>int main(){ int i,n,sum,term; sum=0; term=1; printf("Input n:"); scanf("%d",&n); for(i=1;i<=n;i++) { term*=i; sum+=ter原创 2017-11-14 17:52:37 · 656 阅读 · 0 评论 -
6.18九九乘法表
(1)#include <stdio.h>#include <stdlib.h>int main(){ int i,j,k; char m='-'; for(i=1;i<10;i++) { printf("%d\t",i); } printf("\n"); for(k=1;k<10;k++) {原创 2017-11-18 00:40:40 · 224 阅读 · 0 评论 -
5.7大小写转换
#include <stdio.h>#include <stdlib.h>int main(){ char ch; printf("请输入一个英文字母:"); scanf("%c",&ch); if(ch>='A'&&ch<='Z') { ch=ch+32; printf("%c %d\n",ch,ch); }原创 2017-11-06 16:50:57 · 135 阅读 · 0 评论 -
5.6闰年1
#include <stdio.h>#include <stdlib.h>int main(){ int year,flag; printf("Enter year:"); scanf("%d",&year); if(((year%4==0)&&(year%100!=0))||(year%400==0)) printf("%d is a leap year!原创 2017-11-05 23:25:10 · 140 阅读 · 0 评论 -
5.5闰年
#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; i原创 2017-11-05 23:18:49 · 95 阅读 · 0 评论 -
5.4年利率1
#include <stdio.h>#include <stdlib.h>int main(){ int n,i; float capital,rate,deposit; printf("Input capital,n"); scanf("%f%d",&capital,&n); if(n>0) { switch (n)原创 2017-11-05 00:10:34 · 205 阅读 · 0 评论 -
5.4年利率
#include <stdio.h>#include <stdlib.h>int main(){ int n,i; float capital,rate,deposit; printf("Input capital,n",capital,n); scanf("%f%d",&capital,&n); if(n>0) { switch (n原创 2017-11-05 00:06:48 · 281 阅读 · 0 评论 -
字符语句4.1
4.1(1)#include <stdio.h>main(){ char c1 = 'a',c2 ='b',c3 ='c'; printf("a%cb%cc%c\n",c1,c2,c3); return 0;} (2)#include <stdio.h>main(){ int a=12,b=15; printf("a=%d%% ,b=%d%%\原创 2017-11-03 11:55:26 · 176 阅读 · 1 评论 -
6.10水仙花数
#include <stdio.h>#include <stdlib.h>int main(){ int a,b,c,n; for(n=100;n<1000;n++) { a=n/100; b=(n/10)%10; c=n%10; if(n==a*a*a+b*b*b+c*c*c) pr原创 2017-11-13 13:39:03 · 174 阅读 · 0 评论 -
6.6整存零取
#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){ int i,n; float capital,rate; rate=1.01875; n=12; capital=0; rate=pow(rate,n); for(i=1;i<=5;i++) {原创 2017-11-08 22:37:31 · 564 阅读 · 0 评论 -
6.5
#include <stdio.h>#include <stdlib.h>int main(){ int i,F; float C; for(i=0;i<=300;i=i+10) { F=i; C=(float)5/9*(F-32); printf("%d %f\n",F,C); } return 0;原创 2017-11-08 21:28:04 · 111 阅读 · 0 评论 -
6.4
#include <stdio.h>#include <stdlib.h>int main(){ int i,j,n; long square,cube=1; printf("Input n:"); scanf("%d",&n); for(i=1;i<=n;i++) { square=i*i; cube=i*i*i;原创 2017-11-08 20:58:57 · 128 阅读 · 0 评论 -
6.1
#include <stdio.h>#include <stdlib.h>int main(){ int i,j,k; char space = '2'; for(i=1;i<=4;i++) { for(j=1;j<=i;j++) { printf("%c",space); }原创 2017-11-07 23:06:47 · 133 阅读 · 0 评论 -
文章标题
#include <stdio.h>#include <stdlib.h>int main(){ int year,month; printf("Enter year month "); scanf("%d%d",&year,&month); if(year%4==0&&year%100!=0||year%400==0) { switch原创 2017-11-07 18:32:30 · 98 阅读 · 0 评论 -
if-else
#include <stdio.h>#include <stdlib.h>int main(){ int score,grade; printf("Input score "); scanf("%d",&score); grade=score<0||score>100?-1:score/10; if(score>=90&&score<=100)原创 2017-11-07 17:24:02 · 156 阅读 · 0 评论 -
5.9分数段
#include <stdio.h>#include <stdlib.h>int main(){ int score; printf("Input score "); scanf("%d",&score); if(score>=90&&score<=100) { printf("A"); } else if(score>原创 2017-11-07 16:57:06 · 143 阅读 · 0 评论 -
6.7年利率
#include <stdio.h>#include <stdlib.h>int main(){ int n; float rate,total; total=100.0; printf("Input rate:"); scanf("%f",&rate); for(n=1;total<=200.0;n++) { total=tota原创 2017-11-09 20:51:46 · 311 阅读 · 0 评论 -
最大公约数
#include<stdio.h>main(){ int a,b,r; scanf("%d%d",&a,&b); while(b!=0) { r=a%b; a=b; b=r; } printf("%d\n",a);}知识点:嵌套 while语句原创 2017-11-01 12:03:40 · 109 阅读 · 0 评论 -
6.9
#include <stdlib.h>int main(){ int n=1,count=1,i=1; float e,sum=1.0,term,x; for(n=1;;n++) { i*=n; x=i; if(x>=100000)break; term=1.0/x; sum+=term原创 2017-11-12 23:51:47 · 167 阅读 · 0 评论 -
一元二次方程
3.4#include <stdio.h>#include <stdlib.h>#include <math.h>void main(){ int a,b,c,disc; float x1,x2; printf("请输入 x1,x2\t"); scanf("%d%d%d",&a,&b,&c); disc=b*b-4*a*c; if (disc>0)原创 2017-11-02 23:35:45 · 154 阅读 · 0 评论 -
6.8累加
#include <stdio.h>#include <math.h>int main(){ float sum=0.0; float i=1,j=1; while(1/i>=1e-4) { sum=sum+j/i; j=j*(-1); i+=2; } sum=sum*4; printf("i=%f,%8.原创 2017-11-12 12:20:59 · 140 阅读 · 0 评论 -
6.2
(1)#include <stdio.h>#include <stdlib.h>int main(){ int i,sum; for(i=1;i<=101;i+=2) { sum+=i; } printf("sum=%d\n",sum); return 0;} (2)#include <stdio.h>#include <原创 2017-11-12 00:17:46 · 203 阅读 · 0 评论 -
字母间的转化
#include <stdio.h>#include <stdlib.h>int main(){ char c1,c2; int i=100; c1='a'; i=i-c1; printf("c1:%c\n",c1); printf("c1:%d,i:%d\n",c1,i); c2=c1+4; printf("c2:%c\n",c2); r原创 2017-11-09 22:22:23 · 111 阅读 · 0 评论 -
大小写字母转化
#include <stdio.h>#include <stdlib.h>int main(){ char ch; printf("Input 大写字母:"); ch=getchar(); ch=ch+32; printf("转化的小写字母为:"); putchar(ch); return 0;}原创 2017-11-09 22:00:30 · 184 阅读 · 0 评论 -
分离各位数之和
#include <stdio.h>#include <stdlib.h>int main(){ int x,a,b,c,sum; scanf("%d",&x); a=x/100; b=(x%100)/10; c=x%10; sum=a+b+c; printf("%d\n",sum); return 0;}原创 2017-11-09 21:49:16 · 210 阅读 · 0 评论 -
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原创 2017-11-09 21:12:45 · 103 阅读 · 0 评论 -
输入几个数逆序输出
#include <stdio.h>#include <stdlib.h>int main(){ int a,b,c,*p1,*p2,*p3; scanf("%d%d%d",&a,&b,&c); p1=&a; p2=&b; p3=&c; exchange(p1,p2,p3); printf("%d%d%d\n",a,b,c); re原创 2017-12-13 11:39:56 · 1639 阅读 · 0 评论