今天看到一个问题:编写一个程序,输入一个字符串,可以原样输出,也可以逆向输出,使用条件编译的方法加以控制。
要求用条件编译来做的,怎么也想不出。

[ 本帖最后由 xuzejia_love 于 2012-5-26 01:37 编辑 ]
程序代码:/* ConCom.cpp : Defines the entry point for the console application.*/
#include <stdio.h>
#include <string.h>
#define CON 1
int main(int argc, char* argv[])
{
char str[100];
int i;
printf("Please input a string:");
gets(str);
#if CON
puts(str);
#else
for (i = strlen(str) - 1; i >= 0; i--)
{
putchar(str[i]);
}
putchar(10);
#endif
return 0;
}
