if语句
- Steve Bourne建立了许多预处理定义:
#define STRING char *
#define IF if(
#define THEN ){
#define ELSE }else{
#define FI ;}
#define WHILE while(
#define DO ){
#define OD ;}
#define INT int
#define BEGIN {
#define END }
请将下边代码用 Steve Bourne 大神的方法改写出来:
#include <stdio.h>
int main()
{
int i;
printf("请输入您的年龄:");
scanf("%d", &i);
if (i < 18)
printf("您未满18周岁,不得使用这个程序!\n");
else
printf("您已满18周岁,欢迎使用本程序,嘿嘿嘿...\n");
return 0;
}
答:修改代码如下:
#include <stdio.h>
#define STRING char *
#define IF if(
#define THEN ){
#define ELSE }else{
#define FI ;}
#define WHILE while(
#define DO ){
#define OD ;}
#define INT int
#define BEGIN {
#define END }
INT main()
{
INT i;
printf("please input your age:");
scanf("%d", &i);
IF i < 18)
BEGIN
printf("you are not an adult!\n");
ELSE
printf("you are an adult!\n");
END
return 0;
}
运行结果如下:
dym@ubuntu:~/project/c_proj