正在加载图片...
printf nThis is an isosceles triangle else printf nThis is an unequilateral triangle!") else printf \ nThis is not a triangle 7.简单选择界面的编程。从键盘输入整数,输出不同的字符串: 输入1,输出 Good morning ●输入2,输出 Good afternoon; 输入3,输出 Good evening 输入4,输出 Good night; 输入其他数字,输出 Byebye maino int n: printf( " \nPlease input a number scanf("%d", &n) switch(n) case 1: printf( " Good morning ) break; case 2: printf(" Good afternoon ) break; case 3: printf(" Good evening"); break; case 4: printf("Good night ) break default: printf(" Byebye) 8.已知从银行贷款月利率为:期限一年,为0.90%;期限2年,为1%;期限3年,为1.11% 三年以上为1.2%。从键盘输入贷款金额和期限,计算到期后应归还银行本金和利息合计为 多少钱。 #indude < math h> ma float base rate sum descr: printf( \ eNter the base and the year scanf(%f%d", &base, &year) switch(year) case 1: rate=0. 009: break. case 2: rate=0.01: breakprintf(“\nThis is an isosceles triangle!”); else printf(“\nThis is an unequilateral triangle!”); } else printf(“\nThis is not a triangle!”); } 7. 简单选择界面的编程。从键盘输入整数,输出不同的字符串: ⚫ 输入 1,输出 Good morning; ⚫ 输入 2,输出 Good afternoon; ⚫ 输入 3,输出 Good evening; ⚫ 输入 4,输出 Good night; ⚫ 输入其他数字,输出 Bye bye。 main() { int n; printf("\nPlease input a number:"); scanf("%d",&n); switch(n) { case 1:printf("Good morning");break; case 2:printf("Good afternoon");break; case 3:printf("Good evening");break; case 4:printf("Good night");break; default:printf("Bye bye"); } } 8.已知从银行贷款月利率为:期限一年,为 0.90%;期限 2 年,为 1%;期限 3 年,为 1.11%; 三年以上为 1.2%。从键盘输入贷款金额和期限,计算到期后应归还银行本金和利息合计为 多少钱。 #include <math.h> main() { int year; float base,rate,sum; clrscr(); printf("\nEnter the base and the year:"); scanf("%f%d",&base,&year); switch(year) { case 1: rate=0.009;break; case 2: rate=0.01;break;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有