zoukankan      html  css  js  c++  java
  • 无聊写的奇怪代码(2)

    是这样的……

    今天我考试的时候,闲的无聊,就开始写一串无聊代码

     1 #include<cstdio>
     2 using namespace std;
     3 int main()
     4 {
     5     freopen("1.in","r",stdin);
     6     freopen("1.out","w",stdout);
     7     #include<cstdio>
     8     using namespace std;
     9     int main()
    10     {
    11         freopen("2.in","r",stdin);
    12         freopen("2.out","w",stdout);
    13         return 2;
    14     }
    15     return 1;
    16 }

    就是这个一个套一个的程序……后来层数越来越多了,觉得手打太累,就写了一个小程序帮我输出这玩意

     1 #include<cstdio>
     2 using namespace std;
     3 int m;
     4 void pk(int n)
     5 {
     6     if(n == 0)    return;
     7     for(int i = 1;i <= n;i++)    printf("    ");
     8 }
     9 void p(int n)
    10 {
    11     if(n == m + 1)    return;
    12     pk(n - 1);
    13     printf("#include<cstdio>
    ");
    14     pk(n - 1);
    15     printf("using namespace std;
    ");
    16     pk(n - 1);
    17     printf("int main()
    ");
    18     pk(n - 1);
    19     printf("{
    ");
    20     pk(n);
    21     printf("freopen("");
    22     printf("%d",n);
    23     printf(".in","r",stdin);
    ");
    24     pk(n);
    25     printf("freopen("");
    26     printf("%d",n);
    27     printf(".out","w",stdout);
    ");
    28     p(n + 1);
    29     pk(n);
    30     printf("return ");
    31     printf("%d",n);
    32     printf(";
    ");
    33     pk(n - 1);
    34     printf("}
    ");
    35 }
    36 int main()
    37 {
    38     freopen("hhh.out","w",stdout);
    39     scanf("%d",&m);
    40     p(1);
    41     return 0;
    42 }

    相信有点c艹基础的人都能看懂

    这是输入n = 5的结果

     1 #include<cstdio>
     2 using namespace std;
     3 int main()
     4 {
     5     freopen("1.in","r",stdin);
     6     freopen("1.out","w",stdout);
     7     #include<cstdio>
     8     using namespace std;
     9     int main()
    10     {
    11         freopen("2.in","r",stdin);
    12         freopen("2.out","w",stdout);
    13         #include<cstdio>
    14         using namespace std;
    15         int main()
    16         {
    17             freopen("3.in","r",stdin);
    18             freopen("3.out","w",stdout);
    19             #include<cstdio>
    20             using namespace std;
    21             int main()
    22             {
    23                 freopen("4.in","r",stdin);
    24                 freopen("4.out","w",stdout);
    25                 #include<cstdio>
    26                 using namespace std;
    27                 int main()
    28                 {
    29                     freopen("5.in","r",stdin);
    30                     freopen("5.out","w",stdout);
    31                     return 5;
    32                 }
    33                 return 4;
    34             }
    35             return 3;
    36         }
    37         return 2;
    38     }
    39     return 1;
    40 }

    然后我又试了一下n = 100……

    这个建议自己试一下

  • 相关阅读:
    论文总结
    尝试为有限元模拟加入场的控制
    关于maya动力学系统的一些总结
    实现了与maya场交互的能力
    selenium 3.0鼠标事件 (java代码)
    selenium 常用浏览器操作API
    selenium 3.0与2.0 打开火狐浏览器的区别
    testng+IEDriverServer+yum+tomcat下载软件包
    yum,httpd,php环境搭建方法
    PHP文件环境搭建—EcShop环境搭建
  • 原文地址:https://www.cnblogs.com/aristocrat/p/8561605.html
Copyright © 2011-2022 走看看