#include <iostream> #include<cmath> #include<ctime> #include<string> #include <iomanip> #include <fstream> using namespace std; int main() { int counter = 1; int number = 0; int largest = 0; int n; cin >> n; int occurrence = 0; cout << "Please enter up to 10 numbers and I will print the largest one on the screen.\n\n"; while (counter <= n) { cout << "Number: "; cin >> number; if (largest < number) { largest = number; occurrence = 1; } else if (number == largest) { occurrence++; } if (number == 0) { break; } counter++; } cout << "the largest number is "<<largest << endl; cout << " the occurrence count " << largest << " is " << occurrence << " time"; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter