补交第三次作业
#include<stdio.h>//1.三角形 int main() { printf("*\n"); printf("**\n"); printf("***\n"); printf("****\n"); printf("*****\n"); printf("******\n"); printf("*******\n"); printf("********\n"); printf("*********\n"); printf("**********\n"); }
#include<stdio.h>//2.十行矩形 int main() { printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); printf("**********\n"); }
#include<stdio.h>//3.倒三角形 int main() { printf("**********\n"); printf("*********\n"); printf("********\n"); printf("*******\n"); printf("******\n"); printf("*****\n"); printf("****\n"); printf("***\n"); printf("**\n"); printf("*\n"); }
#include<stdio.h> // 4.五级制成绩 int main() { char score; 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; } }
#include<stdio.h> //6.100米小球落下 #define G 9.8 int main() { int y=3; printf("垂直距离是:%.2f\n",0.5*G*y*y); }
#include<stdio.h> //7. 显示个位数字,十位数字和百位数字的值。 #include<math.h> int main() { int t[10]={0}; int a; scanf("%d",&a); int i=0; while(a!=0) { t[i++]=a%10; a=a/10; } int j; for(j=0;j<=i;j++) printf("%.0f",(t[j]*pow(10,j))); }
#include<stdio.h>//8.分段函数 #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); }