有趣的思考题

来源:互联网 发布:淘宝要3c认证怎么办 编辑:程序博客网 时间:2024/05/16 18:15

饭前看到一个有趣的小问题,水一发~~
1.写一段C++程序,满足下列条件:
a.输出hello。b.删掉第一个字符,输出world。
2.写一段C++程序,满足下列条件:
a.输出hello。b.删掉最后一个字符,输出world。

思考中
……
……
……
……
……
……
……
……
……
……
……
……
……
……
……
1.

//*#define hh//*/#include<stdio.h>#include<iostream>using namespace std; int main(){    bool f=0;    #ifdef hh    f=1;    cout<<"hello"<<endl;    #endif    if(!f) cout<<"world"<<endl;    return 0;}

2.

#include<stdio.h> #include<iostream>using namespace std; #define hh int main(){puts("hello");}  #define h int main(){puts("world");}  hh
0 0
原创粉丝点击