随笔分类 - C语言练习
摘要:#include<stdio.h> void main() { int y, n, s = 0;//定义变量 scanf_s("%d-%d", &y, &n);//输入年月 switch (n)//根据月份判断天数 { case 1:s = 31; break; case 2:s = 28; bre
阅读全文
摘要:#include<stdio.h> void main() { char c; int letter = 0, space = 0, digit = 0, other = 0; printf("请输入需要统计的字段:\n"); while ((c = getchar()) != '\n')//运用g
阅读全文
摘要:#include <stdio.h> int main() { int HH, MM, SS; scanf("%d:%d:%d",&HH,&MM,&SS); SS++; if (SS >= 60) { SS = 0; MM ++; } if (MM >= 60) { MM = 0; HH ++; }
阅读全文
摘要:/* 开发者:慢蜗牛 开发时间:2020.6.11 程序功能:顺序输出和逆序输出 */ #include<stdio.h> #include<malloc.h> #define LEN sizeof(struct L) void print(struct L* head); void _print(
阅读全文
摘要:#include<stdio.h> int main() { double a, b, h, s;//定义变量,上底,下底,高,面积 scanf_s("%lf,%lf,%lf", &a, &b, &h);//输入 s = (a + b) * h / 2.0;//计算面积 printf("%lf",
阅读全文
摘要:#include<stdio.h> void main() { int n, s=0; scanf_s("%d", &n); for (n; n > 0; n--) s += (1 + n) * n / 2; printf("%d", s); }
阅读全文
摘要:/* 开发者:慢蜗牛 开发时间:2020.6.11 程序功能:逆序建立链表,顺序输出 */ #include<stdio.h> #include<malloc.h> #define LEN sizeof(struct once) struct once//建立结构 { int a; struct o
阅读全文
摘要:#include <stdio.h> #include <math.h> void main() { int a, b, c, d, n, h; double t; for (n = 1000; n < 10000; n++) { a = n / 1000; b = (n - a * 1000) /
阅读全文
摘要:#include <stdio.h> void main() { int x, n = 20; double a = 2, b = 1, sws = 0; for (n; n >= 1; n--) { sws = sws + a / b;//运用累加 x = a; //后一项分母等于前一项分子 a
阅读全文
摘要:#include<stdio.h> void main() { int n = 2019, d;//定义变量和常量 d = n % 7;//计算余数 switch (d)//选择星期 { case 1:printf("星期一"); break; case 2:printf("星期二"); break
阅读全文
摘要:LC=(a1,b1,…,am,bm,bm+1,…,bn),m<=n 或者 LC=(a1,b1,…,bn,an,an+1,…,am),m>n /* 开发者:慢蜗牛 开发时间:2020.6.11 程序功能:合并链表 */ #include<stdio.h> #include<malloc.h> #inc
阅读全文
摘要:#include<stdio.h> int main() { int i, j, s;//定义矩形的长,宽,面积变量 scanf_s("%d,%d", &i, &j);//输入长宽的值 s = i * j;//计算面积 printf("%d", s);//输出面积 return 0;//返回0 }
阅读全文
摘要:#include <stdio.h> int main() { double F = 80.0, C;//定义摄氏温度变量,赋值华氏温度 C = 5 * (F - 32) / 9.0;//计算摄氏温度 printf("%lf", C);//输出摄氏温度 return 0; }
阅读全文
摘要:#include <stdio.h> int main() { int n, a, b, c;//定义3位数,个位数,十位数,百位数变量 scanf_s("%d", &n);//输入3位数 a = n % 10;//个位数 b = n / 10 % 10;//十位数 c = n / 100;//百位
阅读全文
摘要:/* 开发者:慢蜗牛 开发时间:2020.5.28 程序功能:计算最大公约数和最小公倍数 */ #include<stdio.h> #include<math.h> int max_(int a, int b); int min_(int a,int b); int max_(int a, int
阅读全文
摘要:#include<stdio.h> void main() { int i, j, k, n=100;//分别设置三个数和一个三位数 for(i=1;i<=9;i++) //一个一个递增来和三位数对比 for(j=0;j<=9;j++) for (k = 0; k <= 9; k++) { if (
阅读全文
摘要:#include<stdio.h> void main() { int n;//定义变量 while (1) { scanf_s("%d", &n); if (n <= 0)//判断是否为正整数 printf("Data error!\n"); else if (n % 5 == 0 && n %
阅读全文
摘要:/* 开发者:慢蜗牛 开发时间:2020.5.28 程序功能:开发公式Cnm */ #include<stdio.h> long fact_1(int m); long fact_2(int n, int m); long fact_1(int m) //求Cnm公示的分母 { int a = m;
阅读全文
摘要:/* 开发者:慢蜗牛 开发时间:2020.5.28 程序功能:小明爬楼梯 */ #include<stdio.h> int taijie(int n); long taijie(int n)//求n台阶数的总方法 { long int i, a[50] = {1,2,4}; for (i = 3;
阅读全文
摘要:代码目前只支持整数转换,小数转换后续更新呀 #include <stdio.h> #include <math.h> void B_O(int n); void B_H(int n); int B_D(int n); void main() { int x,n; while (1) { printf
阅读全文

浙公网安备 33010602011771号