몇가지 배웠던거 짬뽕해서 날림으로 작성해봤다.

뭐 무슨 컵에 뭐 넣고 무슨 컵에 뭐 넣고 출력하는 것인데, 연산까지 넣기엔 이미 졸려버릴 시간이라...나~중에 주말에나 볼만하도록 할 수 있겠다.


#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int main()
{
	bool mainSwitch = false;

	int cup = 0;
	float water = 0.0f;

	char cup1_Name[50] = "";
	string inputS;
	string cup2_Name = "";

	cout << "컵을 실행하시겠습니까? (yes or no)";
	cin >> inputS;

	while (true)
	{
		if (inputS == "no")
		{
			cout << "프로그램을 종료합니다." << endl;
			break;
		}
		else if (inputS == "yes")
		{
			mainSwitch = true;

			while (mainSwitch)
			{
				cout << "첫번째 컵에 무엇을 얼마나 따릅니까? (스페이스바로 입력구분)" << endl;
				cin >> cup1_Name >> water;

				cout << "두번째 컵에 무엇을 얼마나 따릅니까? (스페이스바로 입력구분)" << endl;
				cin >> cup2_Name >> cup;

				cout << "각 컵에 들어간 액체의 종류와 g(gram)수" << endl;
				cout << cup1_Name << " : " << water << "g" << endl;
				cout << cup2_Name << " : " << cup << "g" << endl;

				string outi = "";
				cout << "프로그램을 종료하려면 yes를 계속하시려면 no를 입력해주세요. ";
				cin >> outi;
				if (outi == "yes")
				{
					mainSwitch = false;
					inputS = "no";
				}
			}
		}
		else
		{
			cout << "잘못 입력하셨습니다. yes or no 로 대답해주십시오." << endl;
		}
	}
}


블로그 이미지

irostub

iro의 잡화상점

,