gpt4 book ai didi

c++ - C++ 如何在程序结束后重新启动程序?

转载 作者:行者123 更新时间:2023-11-28 05:18:04 28 4
gpt4 key购买 nike

<分区>

我已经编程了大约一个星期左右,但我无法弄清楚如何在程序结束后用 C++ 重新启动程序。有人能帮我吗?

我编写了这个初学者字母评分程序,它会根据您的分数告诉您您的字母评分。但正如我所说,一旦你到达终点并得到答案,程序就会像预期的那样结束,但我希望它重新启动并让我输入另一个数字。谢谢!

#include <iostream>

using namespace std;

int main()
{

long int grade;
string x = " ";


cout << "Please, enter your grade. (0-100)" << endl;
cin >> grade;

int P =grade == 100;
int A =grade >= 90;
int B =grade >= 80;
int C =grade >= 70;
int D =grade >= 60;
int F =grade >= 0;

if(P){cout << "You have a perfect score." << endl << endl;}else{
if(A){cout <<"You have an A." << endl<< endl; }else{
if(B){cout <<"You have a B." << endl << endl;}else{
if(C){cout <<"You have a C." << endl;}else{
if(D){cout <<"You have a D." << endl<< endl;}else{
if(F){cout <<"You have an F."<< endl<< endl;}else{
cout << "Invalid input.";
}
}
}
}
}
}
cout << "Enter x to finish the program" << endl << endl;
cin >> x;

}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com