/ Vijos / 讨论 / 分享 /

C++的童鞋进来看看

我是一个小菜,最近闲无聊编了一个可以自动打程序框架的东东,对初学者很有用的啦,用C_free可以编译过关
下载源代码或者运行程序的点这里,度娘云盘下载地址:http://yunpan.cn/ccC8HDhEf5piQ 访问密码 3be0
贴上源代码:
各位大请提意见,回去好好修改。

() 
/oo\
______
\ /     ---\
\/    /  \  \
  \|__\_|/  *
   ||  YY|

   ||  ||  
#include<cstdio>
#include<iostream>
#include<cstring>
#include<conio.c>
#include<algorithm>
using namespace std;
FILE *name;
int main()
{
char ss[110];int len,sz=0;
printf("请输入文件名?\n");
scanf("%s",ss);len=strlen(ss);
ss[len]='.';
ss[len+1]='c';
ss[len+2]='p';
ss[len+3]='p';
ss[len+4]='\0';
name=fopen(ss,"w");
clrscr();
printf("请问需要什么头文件?\n");
printf("1.cstdio\n");
printf("2.cstring\n");
printf("3.cmath\n");
printf("4.algorithm\n");
printf("5.conio.c\n");
printf("6.Windows\n");
scanf("%s",ss);len=strlen(ss);
clrscr();
for(int i=0;i<len;i++)
{
if(ss[i]-'0'==1)fprintf(name,"%s\n","#include<cstdio>");
if(ss[i]-'0'==2)fprintf(name,"%s\n","#include<cstring>");
if(ss[i]-'0'==3)fprintf(name,"%s\n","#include<cmath>");
if(ss[i]-'0'==4)fprintf(name,"%s\n","#include<algorithm>");
if(ss[i]-'0'==5)fprintf(name,"%s\n","#include<conio.c>");
if(ss[i]-'0'==6)fprintf(name,"%s\n","#include<Windows>");
}
fprintf(name,"%s\n","using namespace std;");
fprintf(name,"%s\n","int mymax(int x,int y){return x>y?x:y;}");
fprintf(name,"%s\n","int mymin(int x,int y){return x>y?y:x;}");
fprintf(name,"%s\n","int maxx=-9999999,minn=9999999;");
fprintf(name,"%s\n","int main()");
fprintf(name,"%s\n","{");
fprintf(name," %s\n","//freopen(".in","r",stdin);");
fprintf(name," %s\n","//freopen(".out","w",stdout);");
getchar();
int t=0;
printf("要int数组吗?Y/N\n");scanf("%c",&ss[0]);clrscr();
if(ss[0]=='Y'||ss[0]=='y')
{

fprintf(name," %s","int ");
while(1)
{

printf("要什么数组N退出\n");scanf("%s",ss);clrscr();
if(ss[0]=='N'||ss[0]=='n')
{
break; sz=0;
}
else
{
t++;
if(t!=1)fprintf(name,"%s",",");
fprintf(name,"%s",ss);
int t;
sz=0;
while(1)
{
printf("多大?0退出\n");scanf("%d",&t);clrscr();
if(t!=0)
{
fprintf(name,"%s%d%s","[",t,"]");sz=1;
}
else break;
}
getchar();
printf("memset?Y/N\n");scanf("%c",&ss[0]);clrscr();
getchar();
if(ss[0]=='Y'||ss[0]=='y')
{
printf("memset?0,M\n");
scanf("%c",&ss[0]);clrscr();
if(ss[0]=='0'&&sz==0)
{
fprintf(name,"%s","=0");
}
if(ss[0]=='M'||ss[0]=='m'&&sz==0)
{
fprintf(name,"%s","=0x7fffffff");
}
if(ss[0]=='0'&&sz==1)
{
fprintf(name,"%s","={0}");
}
if(ss[0]=='M'||ss[0]=='m'&&sz==1)
{
fprintf(name,"%s","={0x7fffffff}");
}
}
}
}
fprintf(name,"%s\n",";");
}
getchar();t=0;
printf("要long long数组吗?Y/N\n");scanf("%c",&ss[0]);clrscr();
if(ss[0]=='Y'||ss[0]=='y')
{

fprintf(name," %s","long long ");
while(1)
{

printf("要什么数组N退出\n");scanf("%s",ss);clrscr();
if(ss[0]=='N'||ss[0]=='n')
{
break; sz=0;
}
else
{
t++;
if(t!=1)fprintf(name,"%s",",");
fprintf(name,"%s",ss);
int t;
sz=0;
while(1)
{
printf("多大?0退出\n");scanf("%d",&t);clrscr();
if(t!=0)
{
fprintf(name,"%s%d%s","[",t,"]");sz=1;
}
else break;
}
getchar();
printf("memset?Y/N\n");scanf("%c",&ss[0]);clrscr();
getchar();
if(ss[0]=='Y'||ss[0]=='y')
{
printf("memset?0,M\n");
scanf("%c",&ss[0]);clrscr();
if(ss[0]=='0'&&sz==0)
{
fprintf(name,"%s","=0");
}
if(ss[0]=='M'||ss[0]=='m'&&sz==0)
{
fprintf(name,"%s","=0x7fffffff");
}
if(ss[0]=='0'&&sz==1)
{
fprintf(name,"%s","={0}");
}
if(ss[0]=='M'||ss[0]=='m'&&sz==1)
{
fprintf(name,"%s","={0x7fffffff}");
}
}
}
}
fprintf(name,"%s\n",";");
}
getchar();
t=0;
printf("要bool数组吗?Y/N\n");scanf("%c",&ss[0]);clrscr();
if(ss[0]=='Y'||ss[0]=='y')
{

fprintf(name," %s","bool ");
while(1)
{

printf("要什么数组N退出\n");scanf("%s",ss);clrscr();
if(ss[0]=='N'||ss[0]=='n')
{
break; sz=0;
}
else
{
t++;
if(t!=1)fprintf(name,"%s",",");
fprintf(name,"%s",ss);
int t;
sz=0;
while(1)
{
printf("多大?0退出\n");scanf("%d",&t);clrscr();
if(t!=0)
{
fprintf(name,"%s%d%s","[",t,"]");sz=1;
}
else break;
}
getchar();clrscr();
printf("memset?Y/N\n");scanf("%c",&ss[0]);clrscr();
getchar();
if(ss[0]=='Y'||ss[0]=='y')
{
printf("memset?T,F\n");
scanf("%c",&ss[0]);clrscr();
if(ss[0]=='T'||ss[0]=='t'&&sz==0)
{
fprintf(name,"%s","=ture");
}
if(ss[0]=='F'||ss[0]=='f'&&sz==0)
{
fprintf(name,"%s","=false");
}
if(ss[0]=='T'||ss[0]=='t'&&sz==1)
{
fprintf(name,"%s","={true}");
}
if(ss[0]=='F'||ss[0]=='f'&&sz==1)
{
fprintf(name,"%s","={false}");
}
}
}
}
fprintf(name,"%s\n",";");
}
getchar();t=0;
printf("要char数组吗?Y/N\n");scanf("%c",&ss[0]);clrscr();
if(ss[0]=='Y'||ss[0]=='y')
{

fprintf(name," %s","char ");
while(1)
{

printf("要什么数组N退出\n");scanf("%s",ss);clrscr();
if(ss[0]=='N'||ss[0]=='n')
{
break; sz=0;
}
else
{
t++;
if(t!=1)fprintf(name,"%s",",");
fprintf(name,"%s",ss);
int t;
sz=0;
while(1)
{
printf("多大?0退出\n");scanf("%d",&t);clrscr();
if(t!=0)
{
fprintf(name,"%s%d%s","[",t,"]");sz=1;
}
else break;
}
getchar();
printf("memset?Y/N\n");scanf("%c",&ss[0]); clrscr();
getchar();
if(ss[0]=='Y'||ss[0]=='y')
{
printf("memset?All\n");
scanf("%s",ss);clrscr();
if(sz==0)
{
fprintf(name,"%s%s","=",ss);
}
if(sz==1)
{
fprintf(name,"%s%s%s","={",ss,"}");
}
}
}
}
fprintf(name,"%s\n",";");
}
fprintf(name," %s\n","return 0;");

fprintf(name,"%s\n","}");
printf("文件已生成!\n");
system("pause");
return 0;
}

7 条评论

  • @ 2015-08-06 22:57:24

    其实我想想= =你确定手打不比用这玩意要快么= =

  • @ 2015-08-06 22:48:06

    其实你会数据封装么= =就是类与对象= =可以省掉很多麻烦= =而且好修改= =

    • @ 2015-08-06 22:48:49

      然后数组什么的用个template就好了

  • @ 2015-08-02 15:19:36

    0.0

  • @ 2015-08-02 14:09:59

    只有数组没有变量什么鬼。。。还没函数

  • @ 2015-08-01 14:10:20

    有点吊啊

  • @ 2015-07-30 16:28:59

    请在贴代码时选中全部复制过来的代码按一下Tab。Markdown中#代表标题层级,然而Vijos将前几级的标题字号改小了。详情参见内容输入框下方的编辑器快速入门和Markdown详细帮助。

  • @ 2015-07-30 13:48:58

    作为渣渣的我求建议,求方法,求带!
    求大神的帮助!
    大牛,来这里!

  • 1