fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int arr[40];
  6. int *ptr;
  7. int minVal;
  8.  
  9. ptr = arr;
  10. for(int i = 0; i < 40; i++) {
  11. cin >> *ptr;
  12. ptr++;
  13. }
  14.  
  15. ptr = arr;
  16. minVal = *ptr;
  17. for(int i = 0; i < 40; i++) {
  18. if(*ptr < minVal) {
  19. minVal = *ptr;
  20. }
  21. ptr++;
  22. }
  23.  
  24. cout << "The smallest value is: " << minVal << endl;
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5272KB
stdin
12
7
34
5
90
23
11
8
56
32
19
21
45
67
88
2
10
5
6
7
8
9
1
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
stdout
The smallest value is: 1