🍩BC43 及格分数
题目:
代码实现:
#include <stdio.h> int main() { int score; while(scanf("%d",&score)!=EOF) //多组输入,直到没有输入值就停止 { if(score>=60) { printf("Pass\n"); } else { printf("Fail\n"); } } }
🦀BC44 判断整数奇偶性
题目:
代码实现:
#include <stdio.h> int main() { int num1 =0; while(scanf("%d",&num1)!=EOF){ if(num1%2==0){ //一个数%2==0就是偶数 printf("Even\n"); }else if(num1%2==1){ printf("Odd\n"); //一个数%2==1就是奇数 } } }
🫒BC45 最高分数
题目:
答案:
#include <stdio.h> int main() { int a,b,c; int max = 0; scanf("%d %d %d",&a,&b,&c); max = (a>b)?((a>c)?a:c):((b>c)?b:c); printf("%d",max);![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/7943bfd584584e0083d56cb429daec4c.png) return 0; }
🍥BC46 判断是元音还是辅音
题目:
答案:
#include <stdio.h> int main() { char input; while(scanf("%c",&input)!=EOF) { if(input=='\n') //遇到\n需要过滤掉 { continue; } if(input=='a'||input=='A'||input=='e'||input=='E'||input=='i'||input=='I'||input=='o'||input=='O'||input=='u'||input=='U') { printf("Vowel\n"); } else { printf("Consonant\n"); } } }
🍙BC47 判断是不是字母
题目:
答案:
#include <stdio.h> int main() { char input; while(scanf("%c",&input)!=EOF) { if(input=='\n') { continue; } if((input>=65&&input<=90)||(input>=97&&input<=122))//字符底层用ascii码存储,大写字母ascii码范围是65-90,小写字母是97-122 { printf("%c is an alphabet.\n",input); } else { printf("%c is not an alphabet.\n",input); } } }
🌰BC48 字母大小写转换
题目:
答案:
#include <stdio.h> int main() { char ch; while(scanf("%c",&ch)!=EOF) { if(ch>=65&&ch<=90) { printf("%c\n",ch+32); //大写字母+32就是小写字母 参考上面ascii码表 } if(ch>=97&&ch<=122) { printf("%c\n",ch-32); //小写字母-32就是大写字母 } } }
🍜BC49 判断两个数的大小关系
题目:
答案:
#include <stdio.h> int main() { int num1=0; int num2=0; while(scanf("%d %d",&num1,&num2)!=EOF){ //多组输入直到停止输入为止 oj系统会帮助你停止 if(num1>num2){ printf("%d>%d\n",num1,num2); }else if(num1<num2){ printf("%d<%d\n",num1,num2); }else{ printf("%d=%d\n",num1,num2); } } }
🍿BC50 计算单位阶跃函数
题目:
答案:
#include <stdio.h> int main() { int t; while(scanf("%d",&t)!=EOF) { if(t>0) { printf("1\n"); } else if(t==0) { printf("0.5\n"); } else { printf("0\n"); } } }
🍆BC51 三角形判断
题目:
答案:
#include <stdio.h> int main() { int a = 0, b = 0, c = 0; while(~scanf("%d %d %d",&a, &b,&c)) { if(a==b&&b==c) { printf("Equilateral triangle!\n"); } else if((a==b||a==c||b==c)&&(a+b>c && a+c>b && b+c>a)) { printf("Isosceles triangle!\n"); } else if( a+b>c && a+c>b && b+c>a) { printf("Ordinary triangle!\n"); } else { printf("Not a triangle!\n"); } } }
🫓BC52 衡量人体胖瘦程度
题目:
答案:
#include <stdio.h> int main() { int weight,height; while(scanf("%d %d",&weight,&height)!=EOF) { float bmi = weight*1.0/(height*height/10000.0); if(bmi<18.5) { printf("Underweight\n"); } else if(bmi>=18.5&&bmi<=23.9) { printf("Normal\n"); } else if(bmi>23.9&&bmi<=27.9) { printf("Overweight\n"); } else { printf("Obese\n"); } } }
完结
创作不易,还请各位小伙伴多多点赞👍关注✨收藏⭐