Dev C++运行后窗口马上关闭及其一系列问题~

来源:百度知道 编辑:UC知道 时间:2024/05/27 19:49:10
#include <iostream>
using namespace std;
int main()
{ int gotbaha(int);
int n;
cout<<"请输入一个不小于6的偶数."<<endl;
cin >>n;
while (n<6||n%2!=0)
{
cout<<"输入错误,请重新输入一个不小于6的偶数!"<<endl;
cin >>n;
}
int gotbaha(int n);
system("pause");
return 0;
}
int gotbaha(int n)
{
bool prime(int);
int x=3;
for (;x<n-x;x++)
{
if(prime(x)==false||prime(n-x)==false) continue;
else cout<<n<<"="<<x<<"+"<<n-x<<endl; break;

}
return 0;
}
bool prime(int x)
{
int i;
for(i=2;i<x;i++)
{
if(x%i==0) return false;
}
return true;
}
//不是停不住就是停住了没有cout<<n<<"="<<x<<"+"<<n-x<<endl; break;这一句的反应····Help me~

int gotbaha(int); 有这种调用函数的方法吗

#include <iostream>
using namespace std;
int main()
{ int gotbaha(int);
int n;
cout<<"请输入一个不小于6的偶数."<<endl;
cin >>n;
while (n<6||n%2!=0)
{
cout<<"输入错误,请重新输入一个不小于6的偶数!"<<endl;
cin >>n;
}
gotbaha(n); //改成这样
system("pause");
return 0;
}
int gotbaha(int n)
{
bool prime(int);
int x=3;
for (;x<n-x;x++)
{
if(prime(x)==false||prime(n-x)==false) continue;
else cout<<n<<"="<<x<<"+"<<n-x<<endl; break;

}
return 0;
}
bool prime(int x)
{
int i;
for(i=2;i<x/2;i++) //改成这样
{
if(x%i==0) return false;
}
return true;
}

主函数最后再加两条重复的语句用于延迟:
int main()
{
......
cin.get();
cin.get();
}