三角形
#includeint main(){ printf("*\n"); printf("**\n"); printf("***\n"); printf("****\n"); printf("*****\n"); printf("******\n"); printf("*******\n"); printf("********\n"); printf("*********\n"); printf("**********\n"); return 0;}
10*10矩形
#includeint main(){ printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); return 0;}
倒三角形
#includeint main(){ printf("* * * * * * * * * *\n"); printf(" * * * * * * * * *\n"); printf(" * * * * * * * *\n"); printf(" * * * * * * * \n"); printf(" * * * * * * \n"); printf(" * * * * * \n"); printf(" * * * * \n"); printf(" * * * \n"); printf(" * *\n"); printf(" *\n"); return 0;}
输入成绩
#includeint main (){ char score; printf("请输入等级"); scanf("%c",&score); switch(score) { case 'A': printf("90-100"); break; case 'B': printf("80-89"); break; case 'C': printf("70-79"); break; case 'D': printf("60-69"); break; case 'E': printf("0-59"); break; } return 0;}
华氏度
#includeint main(){ int FFF=100; int CCC=5*(FFF-32)/9; printf("CCC=%d",CCC); return 0; }
重力加速度
#includeint main(){ int g=10; int t=3; int h=0.5*g*t*t; printf("h=%d",h); return 0; }
152个位十位百位
#includeint main(){ int x=152; int a=x/100; int b=x%100/10; int c=x%10; printf("百位=%d,十位=%d,个位=%d",a,b,c); return 0;}
分段函数
#include#include 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)=%lf",y); return 0; }
年利率
#include#include int main(){ double money; double year; double rate; double interest; double a; scanf("%lf %lf %lf",&money,&year,&rate); a=pow(1+rate,year); interest=money*a-money; printf("interest=%lf",interest); return 0;}
电量
#includeint main(){ double x; double y; printf("请输入电量x:"); scanf("%lf",&x); if(x<=50) y=x*0.53; else y=50*0.53+(x-50)*0.05; printf("%lf",y); return 0; }
感谢助教老师和丛同学对我的帮助,面对我很弱智的问题还在悉心解答
ps.年利率太难啦