10.17

#include<stdio.h> 
main()
{ 
 int  score;
 char  grade;
 printf("\nplease input a student score:");
 scanf("%d",&score);
 if(score<0||score>100)
  printf("\ninput error!");
 else
  { if(score>=90)
    grade='A';
   else
    { if(score>=80)
      grade='B';
     else
      {if(score>=70)
	     grade='C';
       else
	   { if(score>=60)
	      grade='D';
	   else     
		  grade='E';
	   }
      }
    }
  printf("\nthe student grade:%c",grade);
 }
}    


#include<stdio.h> 
main()
{ 
 int  score,a;
 char  grade;
 printf("\nplease input a student score:");
 scanf("%d",&score);
 if(score<0||score>100)
{
 	printf("\ninput error!");
}
 else
{
 	a=score/10;
 	switch(a)
{
 	case 10:
	case  9:
	grade='A';
	break;
	case 8:	grade='B';
	break;
	case 7:	grade='C'; 
	break;
	case 6:grade='D'; 
	break;
	default:
	grade='E';
	break;	
}
	printf("\nthe student grade:%c",grade);
}
}

第二题
#include <stdio.h>
int main()
{
  int i;
  int qw,bw,sw,gw;
  printf("请输入一个四位数:\n");
  scanf("%d",&i);
  qw=i/1000;    
  bw=(i%1000)/100;//求出百位数字
  sw=(i%100)/10;//求出十位数字
  gw=i%10;
  if(qw<=bw&&bw<=sw&&sw<=gw)
          printf("YES\n") ;
  else
 printf("NO\n") ;
 }   
第三题
#include <math.h>
#include <stdio.h>
main()
{ 
  int i,n;
  long s=0;
  double t;
  printf("请输入n:");
  scanf("%d",&n);
  for(i=1;i<n;i++)
  {
  	if(i%3==0&&i%7==0) 
	s+=i;
  }
  t=sqrt(1.0*s);
  printf("s=%f\n",t);  
}




作业:
第三题
#include <stdio.h>
#include <math.h>
main()
{
	float x;
	printf("请输入实数x:");
	scanf("%f",&x);
	if(x<1)
	{
		printf("y=2*%.2f+3=%8.3f\n",x,2*x+3);
	}
	else if(x>=1&&x<10)
	{
		printf("y=2*%.2f*%.2f-1=%8.3f\n",x,x,2*x*x-1);
	}
	else
	{
		printf("y=√(3*%.2f-4)=%8.3f\n",x,sqrt(3*x-4));
	}
	return 0;   
}

第五题
#include <stdio.h>
int main()
{
	int i;
	printf("第N天是三天打鱼还是两晒网:");
	scanf("%d",&i);
	if(i%5<=3&&i%5!=0)
	printf("第%d天打鱼",i);
	else
	printf("第%d天晒网",i);
	return 0;   
}
第三题

#include <stdio.h>
int main()
{
  int i;
  printf("请输入一个四位数:\n");
  scanf("%d",&i);
  switch(i)
  {
  	case 8888:
  	case 6666:
  	case 4444:
  	case 2222:
    case 0000:
  	printf("YES");
	break;
	default:
	printf("NO"); 
  }
  return 0;
}  



第一题
#include <stdio.h>
int main()
{
  int x,y;
  printf("请输入x:");
  scanf("%d",&x);
  printf("%d\n",3<x<10);
  printf("%d\n",10>x>3);
  printf("%d\n",!x);
  printf("%d\n",x&&2);
  printf("%d\n",x!=0&&1);
  printf("%d\n",x||0);
  printf("%d\n",!x||'0');
  return 0;
}

第四题
#include<stdio.h>
int main()
{
	int c,s;
	float p,w,d,f;
	printf("请输入每公里每吨货物的基本运费、货物重、距离:");
	scanf("%f%f%d",&p,&w,&s);
	if(s>=3000)c=12;
	else c=s/250;
	switch (c)
	{case 0:d=0;break;//break作用使case在次结束
	 case 1:d=1.5;break;//没有break时,结果不正确
	 case 2:
	 case 3:d=3.5;break;
	 case 4:
	 case 5:
	 case 6:
	 case 7:d=8.5;break;
	 case 8:
	 case 9:
	 case 10:
	 case 11:d=9.5;break;
	 case 12:d=15;break;
	}
	f=p*w*s*(1-d/100.0);
	printf("总运费=%2.f\n",f);
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值