![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔记
陈xupeng
这个作者很懒,什么都没留下…
展开
-
【无标题】
输出 150 到 200之间有且仅有一位数字为9的所有整数。要求定义和调用函数is(n, digit)判断正整数n是否有且仅有一位数字为digit,若满足条件则返回1,否则返回0。原创 2021-11-24 22:07:56 · 1610 阅读 · 3 评论 -
“21天好习惯”第一期—18
#include <stdio.h> int main () { int a = 10; do { if( a == 15) { a = a + 1; continue; } printf("value of a: %d\n", a); a++; } while( a < 20 ); return 0; }原创 2021-11-10 23:56:24 · 44 阅读 · 0 评论 -
“21天好习惯”第一期—17
switch镶嵌 #include <stdio.h> int main () { char grade = 'B'; switch(grade) { case 'A' : printf("Excellent!\n" ); break; case 'B' : case 'C' : printf("Well done\n" ); break; case 'D原创 2021-11-09 22:05:59 · 36 阅读 · 0 评论 -
“21天好习惯”第一期—16
“21天好习惯”第一期—16 if的镶嵌语句 #include <stdio.h> int main () { int a = 100; int b = 200; if( a == 100 ) { if( b == 200 ) { printf("Value of a is 100 and b is 200\n" ); } } printf("Exact value of a is : %d\n", a );原创 2021-11-08 23:02:20 · 348 阅读 · 0 评论 -
“21天好习惯“第一期—15
#include <stdio.h> #include <stdlib.h> int main() { int n; int i=1; int sum=1; printf("Please enter n:"); scanf("%d",&n); while(i<=n) { sum=i*sum; i++; } printf("%d\n",sum); return 0; } .原创 2021-11-07 20:59:28 · 38 阅读 · 0 评论 -
“21天好习惯“第一期-14
“21天好习惯”第一期—14 (依旧是if…else) #include <stdio.h> int main () { int a = 100; if( a == 10 ) { printf("Value of a is 10\n" ); } else if( a == 20 ) { printf("Value of a is 20\n" ); } else if( a == 30 ) { printf("Valu原创 2021-11-06 22:17:45 · 207 阅读 · 0 评论 -
“21天好习惯“第一期-13
“21天好习惯”第一期—12 (大小写字母转换) #include <stdio.h> #include <stdlib.h> int main() { char ch,ch1,ch2; ch=getchar(); if (ch>='a'&&ch<='z') ch2=ch-32,ch1=ch2+3; else if(ch>='A'&&ch<='Z') c原创 2021-11-05 22:22:17 · 101 阅读 · 0 评论 -
“21天好习惯”第一期—12
“21天好习惯”第一期—12 计算时间差 #include <stdio.h> #include <stdlib.h> int main() { int hour1,min1,sec1; int hour2,min2,sec2; int num1,num2; int a,b,c,d; scanf("%d:%d:%d%*c%d:%d:%d",&hour1,&min1,&sec1,&hour2,&min2,&sec2); n原创 2021-11-04 21:47:36 · 34 阅读 · 0 评论 -
“21天好习惯”第一期—11
“21天好习惯”第一期—11 (if eles if eles) int main () { int a = 100; if( a == 10 ) { printf("Value of a is 10\n" ); } else if( a == 20 ) { printf("Value of a is 20\n" ); } else if( a == 30 ) { printf("Value of a is 30\n" );原创 2021-11-03 23:23:09 · 39 阅读 · 0 评论 -
“21天好习惯”第一期—10
“21天好习惯”第一期—10 (八进制和十六进制转换) #include <stdio.h> int main(void) { int x = 100; printf("dec = %d; octal = %o; hex = %x\n", x, x, x); printf("dec = %d; octal = %#o; hex = %#x\n", x, x, x); return 0; } ...原创 2021-11-02 23:50:16 · 52 阅读 · 0 评论 -
“21天好习惯”第一期—9
“21天好习惯”原创 2021-11-01 23:03:16 · 42 阅读 · 0 评论 -
“21天好习惯”第一期—8
“21天好习惯”第一期—8 #include <stdio.h> int main() { int x,y,z,t; printf("\n请输入三个数字:\n"); scanf("%d%d%d",&x,&y,&z); if (x>y) { /*交换x,y的值*/ t=x;x=y;y=t; } if(x>z) { /*交换x,z的值*/ t=z;z=x;x=t; }原创 2021-10-31 23:33:57 · 43 阅读 · 0 评论 -
“21天好习惯”第一期—7
“21天好习惯”第一期—8 (简单的if…else…判断数的大小) #include <stdio.h> int main () { int a; scanf("%d",&a); if( a < 20 ) { printf("a is less than 20\n" ); } else { printf("a is not less than 20\n" ); } printf("value of a i原创 2021-10-30 22:52:07 · 51 阅读 · 0 评论 -
“21天好习惯”第一期—6
“21天好习惯”第一期—6 (计算一元二次方程) #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int a=2,b=3,c=1; float x1,x2,disc; disc=b*b-4*a*c; x1=(-b+sqrt(disc))/(2*a); x2=(-b-sqrt(disc))/(2*a); printf("x1=%.4f原创 2021-10-29 22:05:25 · 44 阅读 · 0 评论 -
“21天好习惯”第一期—5
“21天好习惯”第一期—5 (if语句对整数除去其中的偶数,并且不改变符号) #include <stdio.h> #include <stdlib.h> int main() { int a,b=0,t; scanf("%d",&a); t=a/10000%10; if(t%2!=0) { b=b+t; } t=a/1000%10; if(t%2!=0) { b=b*1原创 2021-10-28 22:43:25 · 51 阅读 · 0 评论 -
“21天好习惯”第一期—4
“21天好习惯”第一期—4 (求正余数) #include <stdio.h> int main() { int x,y; int negative,positive; x=(-11)%5; y=(x+5)%5; printf("negative:%d\n",x); printf("positive:%d\n",y); }原创 2021-10-26 21:33:44 · 34 阅读 · 0 评论 -
“21天好习惯”第一期—3
“21天好习惯”第一期—3原创 2021-10-25 22:42:24 · 44 阅读 · 0 评论 -
“21天好习惯”第一期—2
“21天好习惯”第一期—2 #include <stdio.h> #include <stdlib.h> int main() { int x,y,z,t; printf("\n请输入三个数字:\n"); scanf("%d%d%d",&x,&y,&z); if(x>y){ t=x;x=y;y=t; } if(x>z){ t=x;x=z;x=t; } if(y>z){ t=y;y=z;z原创 2021-10-24 22:19:44 · 33 阅读 · 0 评论 -
“21天好习惯”第一期—1
“21天好习惯”第一期—1 #include<stdio.h> int main(void) { double capital; int a,b; printf("year money\n"); scanf("%d",&b); scanf("%lf",&capital); for(a=1;a<=b;a++) { capital=capital*(1+0.0225); } printf("%f",capital); return 0; } ..原创 2021-10-23 22:00:30 · 36 阅读 · 0 评论