{
int putin,total,jo=50,yo=42,jafter=0,gavey=0;
scanf("%d",&putin);
total=putin+jo+yo;
jafter=(float)total/2;
gavey=jafter-yo;
printf("%d",gavey);
return 0;
}
计算盐水浓度
#include <stdio.h>
int main() {
float nacl,water=95,jd;
scanf("%f",&nacl);
jd=nacl/(nacl+water);
printf("%0.2f",jd);
return 0;
}
计算最佳观看距离
#include <stdio.h>
int main() {
float height,pix,jl;
scanf("%f %f",&height,&pix);
jl=height/pix*3400;
printf("%0.2f",jl);
return 0;
}
判断大小月
#include <stdio.h>
int main () {
// TODO 请在此处编写代码,完成题目要求
int i;
scanf("%d",&i);
if(i>0&&i<13)
if(2==i||4==i||6==i||9==i||11==i)
printf("lunar month");
else
printf("solar month");
else
{
printf("error");
}
return 0;
}
判断正负数
#include <stdio.h>
int main () {
// TODO 请在此处编写代码,完成题目要求
int i;
scanf("%d",&i);
if(0!=i)
if(i>0)
printf("positive");
else
printf("negative");
else
{
printf("zero");
}
return 0;
}
判断回文数
#include <stdio.h>
int ishuiwen(int i)
{
int g,s,q,w;
g=i%10;
w=i/10000;
q=i/1000%10;
s=i/10%10;
return g==w&&s==q;
}
int main () {
// TODO 请在此处编写代码,完成题目要求
int i;
scanf("%d",&i);
if(ishuiwen(i))
printf("yes");
else
printf("no");
return 0;
}
判断元辅音
#include <stdio.h>
int main () {
// TODO 请在此处编写代码,完成题目要求
char i;
scanf("%c",&i);
if(i=='a'||i=='e'||i=='i'||i=='o'||i=='u')
printf("vowel sound");
else
printf("consonant sound");
return 0;
}
时间差
#include <stdio.h>
struct TIME
{
int seconds;
int minutes;
int hours;
};
void differenceBetweenTimePeriod(struct TIME t1, struct TIME t2, struct TIME *diff);
int main()
{
struct TIME startTime, stopTime, diff;
startTime.seconds=0;
stopTime.seconds=0;
scanf("%d:%d %d:%d", &startTime.hours, &startTime.minutes, &stopTime.hours, &stopTime.minutes);
// 计算差值
differenceBetweenTimePeriod( stopTime,startTime, &diff);
printf("%d:%d\n", diff.hours, diff.minutes);
return 0;
}
void differenceBetweenTimePeriod(struct TIME start, struct TIME stop, struct TIME *diff)
{
if(stop.seconds > start.seconds){
--start.minutes;
start.seconds += 60;
}
diff->seconds = start.seconds - stop.seconds;
if(stop.minutes > start.minutes){
--start.hours;
start.minutes += 60;
}
diff->minutes = start.minutes - stop.minutes;
d