通过代码生成代码的 文件
- #include
- #include
- using namespace std;
- int main()
- {
- ofstream ofs;
- ofs.open("源.cpp", ios::out);
- ofs<<"#include
\n" ; - ofs<<"using namespace std;\n\n";
- ofs<<"int main()\n";
- ofs<<"{\n";
- ofs<<"\tcout<<\"请给出一个不多于4位的正整数\";\n";
- ofs<<"\tint x;\n";
- ofs<<"\tcin >> x;\n\n";
- ofs<<"\tswitch(x){\n";
-
- int i=1;
- for(;i<10000;i++)
- {
- int len=0;
- int n=i;
- int arr[5];
- while(n) arr[len++]=n%10,n/=10;
- ofs<<"\tcase "<":\n";
- ofs<<"\t\tcout<<\"是"<
"位数\"<; - for(int j=0;j
- {
- if(j==0) ofs<<"\t\tcout<<\"个位数是:"<
0]<<"\"<; - if(j==1) ofs<<"\t\tcout<<\"十位数是:"<
1]<<"\"<; - if(j==2) ofs<<"\t\tcout<<\"百位数是:"<
2]<<"\"<; - if(j==3) ofs<<"\t\tcout<<\"千位数是:"<
3]<<"\"<; - if(j==4) ofs<<"\t\tcout<<\"万位数是:"<
4]<<"\"<; - }
- ofs<<"\t\tcout<<\"倒过来是:";
- for(int j=0;j
- ofs<
- ofs<<"\"<
; - ofs<<"\t\tbreak;"<
- }
- ofs<<"\t}"<
- ofs<<"}"<
- ofs.close();
- }
-
-
-
相关阅读:
AXI VDMA回环测试
【STM32 中断】
Logback原理及应用详解(十五)
【LeetCode刷题-数组】--27.移除元素
探花交友_第2章_环境搭建(新版)
doss攻击为什么是无解的?
lighttpd cgi不能重启
LeetCode[946]验证栈序列
9. Vue3中如何将虚拟节点渲染成真实节点
OpenGL教程(五)
-
原文地址:https://blog.csdn.net/laocooon/article/details/126955286