首页 > 代码库 > 第三次作业
第三次作业
1.编程打印10行的三角形,要求每行显示的*号个数等于行数;
#include<stdio.h>int main (){ printf ("*\n"); printf ("**\n"); printf ("***\n"); printf ("****\n"); printf ("*****\n"); printf ("******\n"); printf ("*******\n"); printf ("********\n"); printf ("*********\n"); printf ("**********");}
2.编程打印10行*号,每行打印10个*号
#include<stdio.h>int main(void){ printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n");}
3.
#include<stdio.h>int main(void){ printf("**********\n"); printf("*********\n"); printf("********\n"); printf("*******\n"); printf("******\n"); printf("*****\n"); printf("****\n"); printf("***\n"); printf("**\n"); printf("*\n");}
4.
#include<stdio.h>
int main()
{
char score;
scanf("%c",&score);
switch (score)
{
case ‘A‘:
printf("100~90");
break;
case ‘B‘:
printf("89~80");
break;
case ‘C‘:
printf("79~70");
break;
case ‘D‘:
printf("69~60");
break;
case ‘E‘:
printf("59~0");
break;
default:
printf("输入有误");
break; }
return 0;
}
5.
#include<stdio.h>int main()//计算华氏温度100°F对应的摄氏温度{ int F=100; int C; printf("C=%d",C=5*(F-32)/9); return 0;}
6.
#include<stdio.h>int main()//计算华氏温度100°F对应的摄氏温度{ int t=3; int a=10; int s; printf("s=%d",s=0.5*a*t*t); return 0;}
7.
#include<stdio.h>int main(){ int a=152; int b; int c; int d; b=a%10; c=(a%100-b)*0.1; d=a/100 ; printf("个位数=%d\n",b);
printf("十位数=%d\n",c);
printf("百位数=%d\n",d);
return 0; }
8.
#include<stdio.h>#include<math.h>int main(){ double x; double y; scanf("%lf",&x); if(x>=0) y=sqrt(x); else y=pow(x+1,2)+2*x+1/x; printf("f(x)=%f",y); return 0;}
9.
#include<stdio.h>#include<math.h>int main(){ int money,year; double rate,interest; printf("请分别输入存款金额、存期、年利率: "); scanf("%d %d %lf",&money,&year,&rate ); interest=money*pow(1+rate,year)-money; printf("interest=%f\n",interest); return 0;}
10
#include<stdio.h>int main(){ int a; double b; scanf ("%d",&a); if(a<=50) {b=a*0.53;} else {b=50*0.53+(a-50)*0.05;} printf ("%lf",b); }
第三次作业
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。