Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- int main()
- {
- int v,max,nr=1,nam;
- printf("Introduceti sirul de elemente:\n");
- int rez = scanf("%i", &v);
- if(!rez)
- {
- do
- {
- fflush(stdin);
- printf("Introdu o valoare corecta:");
- rez = scanf("%i", &v);
- }while( !rez );
- }
- max = v;
- while(scanf("%i",&v))
- {
- if (v > max)
- {
- max = v;
- nam = 1;
- }
- else if ( v == max)
- {
- max =v;
- nam++;
- }
- nr++;
- }
- printf("Numarul de aparitii al maximului este %i,Lungimea sirului este %i,Maximul este %i",nam,nr,max);
- fflush(stdin);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment