大家好,欢迎来到我的学习空间:
1.
#include <stdio.h>
#include <math.h>
int main()
{
double x,result;
scanf("%lf",&x);
if(x>=0)
{result=pow(x,0.5);}
if(x<0)
{
result=pow(x+1,2)+2*x+1.0/x;
}
printf("f(%.2lf) = %.2lf",x,result);
return 0;
}
2.
#include <stdio.h>
#include <math.h>
int main()
{
int N,i;
scanf("%d",&N);
i=N%5;
if(i==1||i==2||i==3){printf("Fishing in day %d",N);}
if(i==0||i==4){printf("Drying in day %d",N);}
return 0;
}
3.
#include <stdio.h>
int main()
{
int a,b,h,f,fen;
scanf("%4d %4d",&a,&b);
if(b%100<a%100)
{f=b%100+60-a%100;
h=b/100-1-a/100;}
else{
f=b%100-a%100;
h=b/100-a/100;
}
printf("%02d:%02d",h,f);
}
4.
#include <stdio.h>
#include <math.h>
int main()
{
int x,y,h;
char ch;
scanf("%d %c %d",&x,&ch,&y);
if(ch=='+')
{h=x + y;
printf("%d",h);}
else if(ch=='-')
{h=x - y;
printf("%d",h);}
else if(ch=='*')
{h=x * y;
printf("%d",h);}
else if(ch=='/')
{h=x / y;
printf("%d",h);}
else if(ch=='%')
{h=x % y;
printf("%d",h);}
else {printf("ERROR");}
return 0;
}
5.
#include <stdio.h>
#include <math.h>
int main()
{
char ch;
scanf("%c",&ch);
if(ch>='0'&&ch<='9')
{
printf("This is a digit.");}
else if(ch>='A'&&ch<='Z')
{
printf("This is a capital letter.");}
else if(ch>='a'&&ch<='z')
{
printf("This is a small letter.");}
else {printf("Other character.");}
return 0;
}
6.
#include <stdio.h>
#include <math.h>
int main()
{
int x;
scanf("%d",&x);
if(x>=60)
{
printf("C语言成绩合格。");}
else {printf("C语言成绩不合格。");}
return 0;
}
7.
#include <stdio.h>
#include <math.h>
int main()
{
int year,month,date,day1=0,day2;
scanf("%4d-%d-%d",&year,&month,&date);
switch(month){
case 12:day1+=30;
case 11:day1+=31;
case 10:day1+=30;
case 9:day1+=31;
case 8:day1+=31;
case 7:day1+=30;
case 6:day1+=31;
case 5:day1+=30;
case 4:day1+=31;
case 3:
if(year%4==0&&year%100!=0||year%400==0)
{day1+=29;}
else{day1+=28;}
case 2:day1+=31;
case 1:day1+=date;}
if(year%4==0&&year%100!=0||year%400==0)
{day2=366+1-day1;
printf("还有%d天到新年",day2);}
else {day2=365+1-day1;
printf("还有%d天到新年",day2);}
return 0;
}
8.
#include <stdio.h>
#include <math.h>
int main()
{ int p,w,s;
double f,d;
scanf("%d %d %d",&p,&w,&s);
if(s<250)
{ d=0;}
else if(s>=250&&s<500)
{
d=0.02;}
else if(s>=500&&s<1000)
{ d=0.05;}
else if(s>=1000&&s<2000)
{ d=0.08;}
else if(s>=2000&&s<3000)
{ d=0.1;}
else{d=0.15;}
f=p*w*s*(1-d);
printf("freight=%.2lf",f);
return 0;
}
今天的分享就到此告一段落了!!!
很高兴能在这里分享我的历程,仅做分享!!!
感兴趣的小伙伴可以留下你们的一键三连吗(●'◡'●)!!!