帮忙修改程序C++语言~~ (输入完一组数据后,这样才能不跳出,能继续输入第二组数据)

来源:百度知道 编辑:UC知道 时间:2024/09/20 07:32:08
//数据处理//
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<math.h>
int panduan(char ch) //判断是否为数字。
{
return (ch>='0'&&ch<='9');
}
int sushu(int a) //判断是否为素数。
{
if (a==0) return 0;
if (a==1) return 0;
if (a==2) return 1;
for(int i=2;i<=sqrt(a);i++)
{
if (a%i==0) return 0;
}
return 1;
}

void work()
{ofstream outf("old.dat"); //创建文件old.dat。
if(!outf)
{
cout<<"Can not open file.\n";
//return 1;
}
char a[100];
cout<<"请输入任意一串字符:\n";
cin>>a;
outf<<a<<endl ; //将字符串存入文件。
outf.close();
ofstream outf1("new1.dat");
ofstream outf2("new2.dat");
if(!outf1)
{
cout<<"Can not open the file new1.dat.\n";
//r

//数据处理//
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<math.h>
int panduan(char ch) //判断是否为数字。
{
return (ch>='0'&&ch<='9');
}
int sushu(int a) //判断是否为素数。
{
if (a==0) return 0;
if (a==1) return 0;
if (a==2) return 1;
for(int i=2;i<=sqrt(a);i++)
{
if (a%i==0) return 0;
}
return 1;
}

int work()
{
char a[100];
cout<<"请输入任意一串字符,输入 0 退出:\n";
cin>>a;
if (strcmp(a,"0")==0)
{
return -1;
}

ofstream outf("old.dat"); //创建文件old.dat。
if(!outf)
{
cout<<"Can not open file.\n";
//return 1;
}

outf<<a<<endl ; //将字符串存入文件。
outf.close();
ofstream outf1("new1.dat");
ofstream outf2("new2.dat");<