您的位置:首页 > 其它

1/28 if

2016-01-28 15:52 344 查看
#include <stdio.h>
// judge the number whether can be divisible by 3 or 5
int main()
{
printf("judge the number a ,whether can be divisible by 3 or 5\n");
int a;
scanf("%d",&a);
int b,c;
b=a%3;
c=a%5;
if ((b==0)||(c==0))
{
printf("%d\n",a);
}
return 0;
}

#include <stdio.h>
//if a+b<100 print a+b
//if a+b>100 print a+b>=10^2
int num_100above(int a)
{
int b;
b=a/10;
return b;
}
int main()
{
printf("please insert a and b\n");
int a,b;
scanf("%d %d",&a,&b);
if(a+b<=100)
{
printf("%d",a+b);
}
else
{
printf("%d",num_100above(a+b));
}
return 0;
}

#include <stdio.h>
//calculate y=x-1(x>=1)
//y=-x+1(x<1)
int main()
{
printf("insert x\n");
int x,y;
scanf("%d",&x);
if(x>=1)
{
y=x-1;
}
else
{
y=-x+1;
}
printf("%d\n",y);
return 0;
}

#include <stdio.h>
#include <math.h>
double yx(double x)
{
double y;
if(x>=0)
{
y=(sin(x)+cos(x))/2.0;
}
else
{
y=(sin(x)-cos(x))/2.0;
}
return y;
}

int main()
{
double y,x;
printf("insert x\n");
scanf("%lf",&x);
y=yx(x);
printf("%f",y);
return 0;
}

#include <stdio.h>
//calculate salary
//h=40
//if h=40 salary=rate*hour
//if h>=40 addition=rate*1.5*addhours
int main()
{
int rate,hours,addhours;
double salary;
printf("insert rate and hours\n");
scanf("%d %d",&rate,&hours);
if(hours<=40)
{
salary=rate*hours;
}
else
{

addhours=hours-40;
salary=40*rate;
salary=salary+addhours*1.5*rate;
}
printf("salary is %f\n",salary);
return 0;
}

#include <stdio.h>
int main()
{
printf("please insert hours and minutes\npay attention to sequence\n");
int hours,minutes;
scanf("%d %d",&hours,&minutes);
if(hours<=9)
{
printf("0");
}
printf("%d:",hours);
if(minutes<=9)
{
printf("0");
}
printf("%d\n",minutes);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: