0:
#include <stdio.h>
int main()
{
int i;
printf("请输入您的年龄:");
scanf("%d", &i);
if (i < 18)
printf("您未满18周岁,不得使用这个程序!\n");
else
printf("您已满18周岁,欢迎使用本程序,嘿嘿嘿...\n");
return 0;
}
1:
#include <stdio.h>
#define IF if(
#define THEN ){
#define ELSE }else{
#define FI ;}
#define INT int
#define BEGIN {
#define END }
INT main()
BEGIN
INT i;
printf("请输入您的年龄:");
scanf("%d", &i);
IF i < 18
THEN
printf("您未满18周岁,不得使用这个程序!\n");
ELSE
printf("您已满18周岁,欢迎使用本程序,嘿嘿嘿...\n");
FI
return 0;
END
2:
#include <stdio.h>
int main()
{
char num;
char up;
char down;
printf("请输入一个字母(大小写均可):");
scanf("%c",&num);
if ( (int)num >= 65 && (int)num <= 90){
down = (int)num + 32;
printf("%c的小写字母为:%c\n",num,down);
}else if( (int)num >= 97 && (int)num <= 122){
up = (int)num - 32;
printf("%c的大写字母为:%c\n",num,up);
}else{
printf("输入有误!");
}
return 0;
}
3:
#include <stdio.h>
#include "ssebtr1.h"
int main()
{
int age, max_hr, bpm, hr; // hr即HeartRate,心率的意思
printf("请输入您的年龄:");
scanf("%d", &age);
max_hr = 220 - age;
bpm = 150;
playSound(bpm);
hr = getHeartRate();
if (hr > max_hr)
{
printf("请马上停止跑步,否则会有绳命危险……\n");
}
else if (hr > max_hr * 0.85)
{
printf("请放慢脚步\n");
bpm = bpm - 20; // 注意,这里需要先修改bpm的值
playSound(bpm); // 你不能在这里传入bpm-20
}
else if (hr < max_hr * 0.75)
{
printf("Come on,请加快节奏!\n");
bpm = bpm + 20;
playSound(bpm);
}
else
{
playSound(bpm);
}
return 0;
}