Untitled
unknown
c_cpp
2 years ago
367 B
6
Indexable
#include <iostream>
int main() {
int total = 0;
float avg = 0;
int count = 0;
int input = 0;
while (true) {
std::cin >> input;
switch(input) {
case 1:
std::cin >> input;
total += input;
count++;
avg = (float)total / count;
break;
case 2:
std::cout << avg << std::endl;
break;
case 3:
return 0;
}
}
}Editor is loading...