do while 2

来源:互联网 发布:软件系统分析师 编辑:程序博客网 时间:2024/05/29 10:37
#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;elsecout << "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;}

0 0
原创粉丝点击