标签:故障 can code 图片 三角形 img 蓝屏 switch 背景
//p1改错
#include <stdio.h> int main() { double x,y; char c1,c2,c3; int a1,a2,a3; scanf("%d%d%d",&a1,&a2,&a3); printf("%d %d %d\n",a1,a2,a3); scanf("%c%c%c",&c1,&c2,&c3); printf("%c%c%c\n",c1,c2,c3); scanf("%lf,%lf",&x,&y); printf("%lf,%lf\n",x,y); return 0; }
//p2验证三角形,没有问题 #include <stdio.h> int main() { double a,b,c; scanf("%lf %lf %lf", &a, &b, &c); if(a<0 || b<0 || c<0) printf("不能构成三角形\n"); else if(a+b>c && a+c>b && b+c>a) { if(a==b || a==c || b==c) { if (a==b && a==c) printf("构成等边三角形\n"); else printf("构成等腰三角形\n"); } else printf("构成一般三角形\n"); } else printf("不能构成三角形\n"); return 0; }
//p2 char变int #include <stdio.h> #include <stdlib.h> int main() { int choice; // 显示菜单 printf("输入0~9以内的数字,选择屏幕背景色前景色方案: \n"); printf("1-\t黑底绿色\n"); printf("2-\t白底黑色\n"); printf("3-\t蓝底白色\n"); printf("其它-\t黑底白色(默认)\n"); printf("\n请输入, 选择你想使用的屏幕配色方案: "); // 要求用户从键盘输入0~9的数字,选择屏幕配色方案 scanf("%d",&choice); // 根据用户输入,设置屏幕配色方案 if (choice == 1) { system("color 02"); printf("《黑客帝国》一类的影视剧常见这种屏幕色:)\n"); } else if(choice == 2) { system("color f0"); printf("大部分编辑器默认是这种配色:)\n"); } else if(choice == 3) { system("color 1f"); printf("这是机器蓝屏故障时的不讨喜色:)\n"); } else { system("color 0f"); printf("控制台程序默认小黑窗:)\n"); } printf("programming is fun, just try@_@\n"); return 0;
}
//p3练习1 #include<stdio.h> int main(){ int a ; printf("请输入一个三为以内的十进制整数:"); scanf("%d",&a); printf("计算其逆序数...\n"); if (a>=0&&a<=9) printf("%d正序和逆序相同\n",a); else if(a>=10&&a<=99){ if(a/10==a-a/10*10) printf("%d正序和逆序相同\n",a); else printf("%d正序和逆序不同\n",a); } else{ if(a/100==a%10) printf("%d正序和逆序相同\n",a); else printf("%d正序和逆序不同\n",a); } return 0; }
p3练习2 # include<stdio.h> # include<stdlib.h> int main(){ int year,month,day; printf("请输入年份 月份:\n"); scanf("%d %d",&year,&month); if(year<1||month<1||month>12) { printf("输入数据有误。\n"); exit(0); } if(year%100==0) { if(year%400==0) {if(month==1) printf("%d年%d月是31天",year,month); else if(month==3) printf("%d年%d月是31天",year,month); else if(month==5) printf("%d年%d月是31天",year,month); else if(month==7) printf("%d年%d月是31天",year,month); else if(month==8) printf("%d年%d月是31天",year,month); else if(month==10) printf("%d年%d月是31天",year,month); else if(month==12) printf("%d年%d月是31天",year,month); else if(month==2) printf("%d年%d月是29天",year,month); else if(month==4) printf("%d年%d月是30天",year,month); else if(month==6) printf("%d年%d月是30天",year,month); else if(month==9) printf("%d年%d月是30天",year,month); else if(month==11) printf("%d年%d月是30天",year,month); } } else if(year%4==0) {if(month==1) printf("%d年%d月是31天",year,month); else if(month==3) printf("%d年%d月是31天",year,month); else if(month==5) printf("%d年%d月是31天",year,month); else if(month==7) printf("%d年%d月是31天",year,month); else if(month==8) printf("%d年%d月是31天",year,month); else if(month==10) printf("%d年%d月是31天",year,month); else if(month==12) printf("%d年%d月是31天",year,month); else if(month==2) printf("%d年%d月是29天",year,month); else if(month==4) printf("%d年%d月是30天",year,month); else if(month==6) printf("%d年%d月是30天",year,month); else if(month==9) printf("%d年%d月是30天",year,month); else if(month==11) printf("%d年%d月是30天",year,month); } else if(month==1) printf("%d年%d月是31天",year,month); else if(month==3) printf("%d年%d月是31天",year,month); else if(month==5) printf("%d年%d月是31天",year,month); else if(month==7) printf("%d年%d月是31天",year,month); else if(month==8) printf("%d年%d月是31天",year,month); else if(month==10) printf("%d年%d月是31天",year,month); else if(month==12) printf("%d年%d月是31天",year,month); else if(month==2) printf("%d年%d月是28天",year,month); else if(month==4) printf("%d年%d月是30天",year,month); else if(month==6) printf("%d年%d月是30天",year,month); else if(month==9) printf("%d年%d月是30天",year,month); else if(month==11) printf("%d年%d月是30天",year,month); return 0; }
p3练习3 #include<stdio.h> int main(){ int a; printf("输入分数(0~100):"); scanf("%d",&a); switch(a/10) { case 0: case 1: case 2: case 3: case 4: case 5:printf("不及格\n");break; case 6:printf("及格\n");break; case 7:printf("中等\n");break; case 8:printf("good\n");break; case 9: case 10:printf("perfect\n");break; } return 0; }
标签:故障 can code 图片 三角形 img 蓝屏 switch 背景
原文地址:https://www.cnblogs.com/wyxnb/p/11788183.html