标签:can 3.0 ble 成绩 math error double asc print
3.1
#include<stdio.h>
int main()
{
char a;
scanf("%c",&a);
if(a>=65&&a<=90) //大写字母的ASC码值范围
printf("%c\n",a+32); //a+32代表ASC码值增加,大写转变为小写
else if(a>=97&&a<=122) //小写字母的ASC码值范围
printf("%c\n",a);
else
printf("Not letter!\n");
}
3.2
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
if(n%15==0) //同时是3和5倍数,一定是15倍数,%号代表取余数
printf("Yes\n");
else
printf("No\n");
}
3.3
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
{
if(b>c)
printf("%d,%d,%d\n",a,b,c);
else
printf("%d,%d,%d\n",a,c,b);
}
else
printf("%d,%d,%d\n",c,a,b);
}
else
{
if(c<b)
{
if(a>c)
printf("%d,%d,%d\n",b,c,a);
else
printf("%d,%d,%d\n",b,a,c);
}
else
printf("%d,%d,%d\n",c,b,a);
}
}
3.4
#include<stdio.h>
int main()
{
double x;
scanf("%lf",&x);
if(x>0)
printf("x=%lf,f(x)=1\n",x);
else if(x==0)
printf("x=%lf,f(x)=0\n",x);
else
printf("x=%lf,f(x)=-1\n",x);
}
3.5
#include<stdio.h>
int main()
{
double data1,data2;
char op;
scanf("%lf%c%lf",&data1,&op,&data2);
switch(op)
{
case ‘+‘:printf("%lf+%lf=%lf",data1,data2,data1+data2);break;
case ‘-‘:printf("%lf-%lf=%lf",data1,data2,data1-data2);break;
case ‘*‘:printf("%lf*%lf=%lf",data1,data2,data1*data2);break;
case ‘/‘:printf("%lf/%lf=%lf",data1,data2,data1/data2);break;
}
}
3.6
#include<stdio.h>
int main()
{
int s;
double ss;
printf("please input s=");
scanf("%d",&s);
if(s>=0&&s<80)
ss=0;
else if(s>=80&&s<90)
ss=100+s;
else
ss=200+s*3.0/2;
printf("成绩=%d,奖学金ss=%.2lf\n",s,ss); //%.2lf表示确定到小数点后两位
}
3.7
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
int a,b;
scanf("%d",&a);
srand((unsigned)time(NULL));
b=rand()%10+1;
if(a==b)
printf("OK\n");
else
printf("ERROR\n");
}
标签:can 3.0 ble 成绩 math error double asc print
原文地址:http://www.cnblogs.com/cdp1591652208/p/6512437.html