Advertisement
STANAANDREY

sb prog 10

Feb 23rd, 2022
1,062
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int n, v[100];
  4.  
  5. void read(int &n, int v[]) {
  6.     cin >> n;
  7.     for (int i = 0; i < n; i++) {
  8.         cin >> v[i];
  9.     }
  10. }
  11.  
  12. void write(int n, int v[]) {
  13.     for (int i = 0; i < n; i++) {
  14.         cout << v[i] << ' ';
  15.     }
  16.     cout << endl;
  17. }
  18.  
  19. int getMini(int n, int v[]) {
  20.     int mini = v[0];
  21.     for (int i = 1; i < n; i++) {
  22.         if (mini > v[i]) {
  23.             mini = v[i];
  24.         }
  25.     }
  26.     return mini;
  27. }
  28.  
  29. int main() {
  30.     read(n, v);
  31.     write(n, v);
  32.  
  33.     int mini = getMini(n, v);
  34.     cout << mini << endl;
  35.  
  36.     for (int i = 0; i < n; i++) {
  37.         if (mini == v[i]) {
  38.             cout << i << ' ';
  39.         }
  40.     }
  41.  
  42.     return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement