自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(24)
  • 收藏
  • 关注

原创 从小到大排序if语句

#include <stdio.h>int main(){ int a, b, c,t; printf("请输入三个整数:"); scanf_s("%d%d%d", &a, &b, &c); if(a>b) { t = a; a = b; b = t; } if(a>c) { t = a; a = c; c = t; } if(b>c)...

2022-04-08 19:15:00 208

原创 成绩等级switch语句

#include<stdio.h>#include<math.h>int main(){ int x; char grade; printf("请输入一个同学成绩"); scanf_s("%d", &x); switch (x / 10) { case 10: case 9: grade = 'A'; break ; case 8: ...

2022-04-07 18:17:55 397

原创 循环语句阶乘C语言

#include<stdio.h>#include<math.h>int main(){ int i, n; double factorial; printf("输入n的值:"); scanf_s("%d", &n); factorial = 1; for (i = 1; i <= n; i++) factorial = factorial * i; printf("%f\n", facto...

2022-04-06 21:39:26 606

原创 循环累加求和问题

include<stdio.h>#include<math.h>int main(){ double sum, item, flag, denominator; sum = 0; item = 1; flag = 1; denominator = 1; while (fabs(item) >= 1e-6) { sum = sum + item; flag = -flag; denominato...

2022-04-05 19:20:50 148

原创 c语言的循环简单语句

#include<stdio.h>#include<math.h>int main(){ int n =13,year;double number,rate;rate=0.02;for(year=1;year<=10;year++){number=n*pow((1+rate),year);printf("%2d年后,人数为:%.2f亿\n",year,number);;} return 0;}

2022-04-04 19:42:39 412

原创 判断是不是升序数

#include<stdio.h> int main (){int n,a,b,c;printf("请输入一个3位整数:");scanf("%d",&n);if(n<100||n>999)printf("输入错误!\n");else{a=n/100;b=n/10%10;c=n%10;if(a<b&&b<c)printf("%d是生序数",n);elseprintf("%d不是升序数",n);.

2022-04-03 20:16:20 1744

原创 多分支格式判断闰年

#include <stdio.h>int main(){ int year, leap; printf("输入月份"); scanf_s("%d", &year); if (year % 4 != 0) leap = 0; else if (year % 100 != 0) leap = 1; else if (year % 400 != 0) leap = 0; else...

2022-04-02 21:42:58 698

原创 输入一个年份判断是不是闰年

#include<stdio.h>int main(){ int year, leap; printf("输入年份:"); scanf_s("%d", &year); if (year % 4 == 0) { if (year % 100 == 0) { if (year % 400 == 0) leap = 1; else ...

2022-04-01 21:17:54 674

原创 用switch语句根据年月份判断每个月的天数

#include <stdio.h> int main (){int month,days,year;switch(month){case1:case3:case5:case7:case 8:case10:case12:days=31;break;case4:case6:case9:case11:days=30;break;case2:if(year%4=0&&year%100!=0||year%..

2022-03-31 19:12:37 4787

原创 一个月份是第几季度输出

#include <stdio.h>int main(){ int month; printf("输入月份"); scanf_s("%d", &month); switch ((month - 1) / 3) { case 0: printf("%d月是第一季度\n", month); break; case 1: printf("%d月是第二季度\n", month); ...

2022-03-30 17:50:14 1149

原创 多分支if语句成绩等级

#include <stdio.h>int main(){int a,grade;printf("请输入一个同学成绩");scanf("%d",&a);if(a>=90)grade='A'; else if(a>=80) grade='B'; else if (a>=70) grade='C'; else if (a>=60) g...

2022-03-29 19:30:40 976

原创 分段函数的编辑语言

#include<stdio.h>int main(){ int x, y; scanf_s("%d", &x); if (x > 0) y = 1; else if (x == 0) y = 0; else y = -1; printf("y=%d\n",y); return 0;}...

2022-03-28 22:07:18 207

原创 if语句的三个数大小比较

#include <stdio.h>int main(){ int a, b, c, max; scanf_s("%d%d%d", &a, &b, &c); if (a > b) if (a > c) max = a; else max = c; else if (b > c) max = b; else ...

2022-03-27 21:27:41 3879 2

原创 三个数从大到小排列

#include <stdio.h># include<math.h>int main(){ float a, b, c, t; scanf_s("%f,%f,%f", &a, &b, &c); if (a > b) {t = a; a = b; b = t;} if(a>c) {t = a; a = c; c = t;} if(b>c) { t = b; ...

2022-03-26 16:43:52 276

原创 两个整数的大小比较

#include<stdio.h>int main(){ int a, b; printf("请输入两个整数"); scanf_s("%d%d", &a, &b); if (a > b) printf("两个整数中最大数为:%d\n", a); else printf("两个整数中的最大数为:%d\n", b); return 0;}...

2022-03-25 18:39:03 635

原创 判断语句 三角形面积能否构成

#include<stdio.h>#include<math.h>int main(){ int a, b, c; float area; float s; printf("请输入三角形的三条边:"); scanf_s("%d,%d,%d", &a, &b, &c); s = (a + b + c) / 2.0; if (a + b <= c || b + c <= a || a + c...

2022-03-24 22:03:24 302

原创 一元二次方程根...

#include <stdio.h># include<math.h>int main(){ float a,b,c,x1,x2,p,q;printf("请输入三个系数");scanf_s("a=%f,b=%f,c=%f", &a, &b, &c);p = -b / (2 * a);q = sqrt(b * b - 4.0 * a * c);x1 = p + q;x2 = p - q;printf("x1=%5.2f\n,x2=%5...

2022-03-23 22:08:15 247

原创 输入函数与输出函数

#include<stdio.h> int main(){ int a, b, c, d; scanf_s("%2d%3d%*d,%d%d", &a, &b, &c, &d); printf("a=%d,b=%d,c=%d,d=%d\n", a, b, c, d); printf("a=%4d,b=%-4d,c=%-4d,d=%4d\n", a, b, c, d); printf("a=%+4d,b=%+4d,c=%+...

2022-03-22 22:17:49 590

原创 华氏温度转化为摄氏度

/*将华氏温度转化为摄氏温度*/#include<stdio.h>int main(void){ /*定义2个整型变量,celsius表示摄氏温度,fahr表示华氏温度*/ int celsius, fahr; printf("输入华氏温度:"); scanf_s("%d", &fahr); celsius = 5 * (fahr - 32) / 9; printf("华氏温度为:%d,摄氏温度为:%d\n", fahr, celsi...

2022-03-21 22:30:26 550

原创 【无标题】

seizof 计算字节符函数int 整数类型float 浮点型单精度double 双精度+= 例如 a+=10 等于 a=a+10++a自增 但和a++稍微不同 例如在 a=++x x=1时a等于2 然而a++等于1--a 和a--和自增类似。注意代码主干需要用逗号分开。...

2022-03-20 21:31:55 224

原创 【无标题】求字节运算符

#include<stdio.h>int main (){ int a = 3,b = 4;float c;c = (float)(a + b) / 2;printf("c=%f\n", c);printf("char类型占%d字节\n", sizeof(char));printf("short int类型占%d字节\n", sizeof(short int));return 0;}

2022-03-19 21:46:29 75

原创 短整型变量溢出 各种数据类型

#include <stdio.h>int main(){ int i,j=7; int a,b,c,d; short int g,h; g=32767; h=g+1; printf("g=%d,h=%d\n",g,h); unsigned long e; a=5;b=6;e=10; c=a+e; d=b+e; printf("c=%d,d=%...

2022-03-18 22:21:45 353

原创 3.17号

#include <stdio.h>int main (){ int a,b,t,c,ge,shi,bai; a=56; b=32; t=a; a=b; b=t; c=103; ge=c/100; bai=c%10; shi=c/100-1;printf("%d,%d\n",a,b);printf("%d%d%d",bai,shi,ge);return 0;}

2022-03-17 22:03:56 802

原创 圆的体积表面积和和字符型变量

#include <stdio.h>#define pi 3.14159int main(){ char c1,c2; int r; float v,f;\ r=2; v=4.0*pi*r*r*r/3; f=4.0*pi*r*r; c1='A'; c2=c1+32; printf("%d,%d \n",c1,c2); printf("%c,%c\n",c1,c2); printf("体积为%f,表面积为%f\n",...

2022-03-16 22:22:13 322

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除