while (pin != 1234) { std::cout << "Incorrect PIN. Enter your PIN again: "; std::cin >> pin; }
换行符
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<iostream> usingnamespace std;
intmain(){ string name; // Ask for the name input cout << "Enter your name: "; cin >> name; // Output the chained sentences with newline after each one cout << "In the name of the Warrior, I charge you to be brave.\n" << "In the name of the Father, I charge you to be just.\n" << "In the name of the Mother, I charge you to defend the innocent.\n" << "Arise, " << name << ", a knight of the Seven Kingdoms." << endl;
#include<iostream> usingnamespace std; intmain(){ for(int i=2;i>0;i--){ cout<<i<< " bottles of beer on the wall\n" <<i<<" bottles of beer\n" <<"Take one down, pass it around\n" <<i-1<<" bottles of beer on the wall"<<endl; } return0; }