repl.it
@justingraham/

Online Exercises

C++

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// http://www.cplusplus.com/forum/articles/12974/

#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;


// Soda Machine
int main() 
{
/*	vector<string> sodas{"Coke", "Sprite", "Dr. Pepper", "Pepsi", "Big Red"};
	cout << "Coka Cola Machine 300\n";
	cout << "Available Options: \n";
	for(int i; i < sodas.size(); i++)
	{
		cout << i + 1 << ") " << sodas[i] << endl;
	}
	
	int soda;
	cout << "\nWhich soda would you like? (1-5): ";
	cin  >> soda;
	
	while(cin.fail() || soda > 5 || soda < 1)
	{
		cin.clear();
		cin.ignore(99999, '\n');
		cout << "Incorrect selection. Which soda would you like? (1-5): ";
		cin  >> soda;
	}
	
	cout << "You selected soda #" << soda << ") " << sodas[soda] << endl;
*/

//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////

/*
	int number = 1;
	vector<int> limit;
	int i = -1;
	while(number != i && limit.size() < 10)
	{
		i++;
		cout << "Enter a number other than " << i << ": ";
		cin  >> number;
		limit.push_back(number);
	}
	
	if(number == 5)
	{
		cout << "\nHey! you weren't supposed to enter " << i << "!";
	}
	else
	{
		cout << "\nWow, you're more patient than I am, you win!";
	}
*/

//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Pancakes Glutton
/*
	int i, min, max, pers[10];
	
	cout << "How many pancakes did the following persons ate?\n";

	for(i = 1; i <= 10; i++)
	{
		cout << "Person " << i << ": ";
		cin >> pers[i];
	}

	min = pers[1];
	max = pers[i];

	for(i = 2; i <= 10; i++)
	{
		if(min>pers[i])  // calculez min
		{
			min=pers[i];
		}
	   if(max<pers[i])  // calculez max
	   {
	      max=pers[i];
	   }
	}

	for(i = 1; i <= 10; i++)
	{
		if(min == pers[i])
		{
			cout<<"\nPerson " << i << " ate the least pancakes! (" << min << ")";
		}
		if(max == pers[i])
		{
			cout<<"\nPerson " << i << " ate the most pancakes! (" << max << ")";
		}
	}
	*/
	
	
}
Fetching token
?