, codereview, , ( codereview)
. , :
using namespace std;
int main() {
string question;
cout << "Type [1] to begin...";
cin >> question;
if(question == "1") {
cout << "A computer programmer figures out the process of
designing, writing, testing, debugging, and maintaining the source c
ode for computer programs";
return 0;
}
}
- IDE, IDE , , < img src= "https://i.stack.imgur.com/IhRE4.png" alt= " " > .
, .
, -, - , , , .
, , ,
- , .
- , :
?
4b. , .
- , .
- ..
, , :
.
repeat
, . repeat
, , . ( youtube, ), do-while
.
:
do {
// Ask the user a question
// Get the user input
// validate the user input
// if they want to see the slide show it
// other wise, leave this loop
while (I have not run out of slides);
psuedo-code, :
#include <iostream>// cin, cout
#include <string> // string
#include <vector> // vector
#include <cstddef> // size_t
using namespace std;
int main() {
vector<string> slides = {
"A computer programmer figures out the process of"
"designing, writing, testing, debugging, and maintaining the source c"
"ode for computer programs",
"what are programming languages?",
};
size_t current_slide_index = 0;
string user_response;
do {
cout << "Type [1] to continue: ";
cin >> user_response;
cin.ignore(100, '\n');
if (user_response == "1") {
cout << slides.at(current_slide_index) << std::endl;
} else {
break;
}
} while (++current_slide_index < slides.size());
cout << "Happy learning\n";
return 0;
}
vector
, . ++. , .cin >>
-, . cin.ignore(100, '\n');
, codereview
, , , , , https://codereview.stackexchange.com/.