首页 > 代码库 > C语言第三次作业
C语言第三次作业
#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");}
#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");}
#include<stdio.h>int main(void){ printf("* * * * * * * * * *\n"); printf("* * * * * * * * * *\n"); printf("* * * * * * * * * *\n"); printf("* * * * * * * * * *\n"); printf("* * * * * * * * * *\n"); printf("* * * * * * * * * *\n"); printf("* * * * * * * * * *\n"); printf("* * * * * * * * * *\n");}
整数152的各位数
#include<stdio.h>int main(){ int a,b,c,d; a=152; b=a%10; c=(a-b)%100/10; d=a/100; printf("%d %d %d",b,c,d);}
自由落体
#include<stdio.h>int main(){ int t=3; int g=10; int height; height=0.5*g*t*t; printf("%d",height);}
存款利息
#include<stdio.h>int main(){ int money; int year; int rate; double interest; printf("请输入money year rate的值"); scanf("%d %d %d",money,year,rate); interest=money*(1+rate,year)-money; printf("%f",interest); }
电费
#include<stdio.h>#include<math.h>int main(){ double x; double cost; printf("请输入x的值"); scanf("%lf",&x); if(x>0&&x<=50) printf("cost=%f",cost=0.53*x); else if(x>50) printf("cost=%f",cost= 50*0.53+(x-50)*0.58); else printf("Invalid Value!"); }
分段函数1
#include<stdio.h>int main(){ int x; double y; printf("请输出x的值"); scanf("%d",&x); if (x==0) y=0; else y=1/(double)x; printf("%f",y);}
分段函数2
#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);}
A,B,C,D,E的等级
#include<stdio.h>int main(){ char score; scanf("%c",&score);//A,B,C,D,E 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; default: printf("输入有误"); }}
C语言第三次作业
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。