Advertisement
dzieciol

najwieksze liczby

Oct 27th, 2014
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1.     srand(time(NULL));
  2.     int i,b,c;
  3.     b=0;
  4.     c=0;
  5.     int tab[31];
  6.     for (i=0;i<31;i++)
  7.     tab[i]=rand()%10;
  8.     for (i=0;i<31;i++)
  9.     cout<<tab[i]<<",";
  10.     cout<<endl;
  11.     for(i=0;i<31;i++){
  12.     b=b+tab[i];
  13.     if (tab[i]>c)
  14.     c=tab[i];
  15. }
  16. int d=0;
  17. for (i=0;i<31;i++)
  18. if (tab[i]==c)
  19. d++;
  20. int g=0;
  21.     cout<<b<<endl;
  22.    cout<<"najwieksza liczba to "<<c<<" wystepuje "<<d<<" razy"<<endl;
  23.    for (i=0 ;i<31;i++)
  24.    if (tab[i]!=c)
  25.  
  26.    if (tab[i]>g)
  27.    g=tab[i];
  28.    cout<<"druga najwieksza liczba to "<<g<<endl;
  29.  system("pause");
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement