do while 2

#include <iostream>
#include <string>

using namespace std;

int main ()
{ 
     string rsp;
	do{
		cout << "Please enter two values: ";
		int i, j;
		cin >> i >> j;
		cout << "The sum of " << i << " + " << j << " = " << i + j << "\n\n"
			 << "More? [Yes][no]";
		cin >> rsp;
	}while(!rsp.empty() && rsp[0] != 'n');

    string k1,k2,k3;
	do
	{
		cout << "Enter two strings: " << endl ;
		cin >> k1 >> k2;
		if(k1 < k2)
		    cout << "The first string is smaller than the second one." << endl;
		else if(k1 == k2)
			cout << "Two strings are equals. " << endl;
		else
			cout << "The second string is smaller than the first one. ";
		cout << "Continue? (y-yes, n-no)" << endl;
		cin >> k3;
	}while(k3[0] != 'n' && k3[0] != 'N'); 


	return 0;
}

你可能感兴趣的:(do while 2)