• 【积累】一道有趣的签到题


    题目链接

    题目描述

    写一个程序,使其能输出自己的源代码。

    代码中必须至少包含十个可见字符。

    输入格式

    输入文件为空。

    输出格式

    你的源代码。


    从来没想过还可以这么玩φ(゜▽゜*)♪

    看着别人的题解写了一份代码:

    #include<bits/stdc++.h>
    #define kk(x) #x
    using namespace std;
    char s[]=kk(int main(){puts("#include<bits/stdc++.h>");puts("#define kk(x) #x");puts("using namespace std;");printf("char s[]=kk(");printf("%s",s);puts(");");puts(s);});
    int main(){puts("#include<bits/stdc++.h>");puts("#define kk(x) #x");puts("using namespace std;");printf("char s[]=kk(");printf("%s",s);puts(");");puts(s);}

    然后了解了一个以前不知道的知识点:C++#号的使用

    1,#     字符串化 

    2,##   连接字符串

    3,#@  字符化(据说gcc编译器不行,微软特有)

    #include<cstdio>
    #define k(x) #x
    #define kk(x) num##x
    int main()
    {
        printf(k(=-=)"
    ");
        int numy=7;
        int t=kk(y);
        printf("%d",t);
    }
    /*
    输出:
    =-=
    7
    */

    在这道题用#代替引号可以避免引用引号的一些麻烦

  • 相关阅读:
    移动端图片按比例裁剪
    bootstrap悬停下拉菜单显示
    videojs兼容ie8
    ie浏览器不支持多行隐藏显示省略号
    rem和px
    浏览器默认返回,页面刷新
    centos src compile gcc 7.3
    docker与gosu
    centos 安装 kernel
    docker proxy
  • 原文地址:https://www.cnblogs.com/kkkek/p/11629001.html
Copyright © 2020-2023  润新知