Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // se citește n de la tastatură, apoi n numere,
- // să se calculeze de câte ori apare în șir numărul maxim
- // 8
- // 3 7 4 7 3 1 2 6
- int main() {
- int a[1005], n, i, max, c;
- cin>>n;
- for(i = 1; i <= n; i++) {
- cin>>a[i];
- }
- max = a[1];
- for(i = 1; i <= n; i++) {
- if(a[i] > max) {
- max = a[i];
- }
- }
- c = 0;
- for(i = 1; i <= n; i++) {
- if(max == a[i]) {
- c ++;
- }
- }
- cout<<c<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement