SHARE
TWEET

slavkec

a guest May 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. START: 9.4
  3. Imamo n celih števil, ki so si po velikosti zelo blizu(se ponavljajo), npr imamo 15 števil med 1 in 10()%10+1
  4. Program naj poišèe vse maksimume(èe jih je veè).
  5. */
  6. #include <iostream>
  7. #include<time.h>
  8. #include<stdlib.h>
  9.  
  10. using namespace std;
  11.  
  12. int napolni(int stevila[],int n){
  13.     for(int i=0;i<n;i++)
  14.         stevila[i] = rand()%10+1;
  15. }
  16. int izpis(int stevila[],int n){
  17.     for(int i=0;i<n;i++)
  18.         cout<<stevila[i]<<" ";
  19. }
  20. int en_maks(int stevila[],int n){
  21. int maks = 0;
  22.     for(int i=0;i<n;i++){
  23.         if(stevila[i] > maks)
  24.             maks = stevila[i];
  25.     }
  26. return maks;
  27. }
  28.  
  29. int vsi_max(int stevila[], int n,int max_stevilo){
  30.  
  31. for(int i=0;i<n;i++){
  32.     if(stevila[i] == max_stevilo){
  33.         cout<<"\nMax "<<max_stevilo<<" je na indexu "<<i;
  34.     }
  35. }
  36.  
  37. }
  38.  
  39.  
  40. int main(){
  41. int n;
  42. srand(time(0));
  43. cout<<"Vnesi n: ";
  44. cin>>n;
  45. int stevila[n];
  46. napolni(stevila, n);
  47. izpis(stevila, n);
  48. cout<<"\nMaksimum: "<<en_maks(stevila, n);
  49. int max_stevilo = en_maks(stevila, n);
  50. vsi_max(stevila, n, max_stevilo);
  51.  
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top