Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6. int randint(int a, int b) {
  7.     return (rand() % (b - a + 1)) + a;
  8. }
  9.  
  10.  
  11. int main(void) {
  12.     srand(time(0));
  13.  
  14.     int a[10];
  15.     for (int i = 0; i < 10; i++) {
  16.         a[i] = randint(-10, 10);
  17.         printf("%d ", a[i]);
  18.     }
  19.  
  20.     int min_value = 1005;
  21.     for (int i = 0; i < 10; i++) {
  22.         if (a[i] < min_value) {
  23.             min_value = a[i];
  24.         }
  25.     }
  26.  
  27.     printf("\nMin indexes: ");
  28.     for (int i = 0; i < 10; i++) {
  29.         if (a[i] == min_value) {
  30.             printf("%d ", i);
  31.             a[i] = 0;
  32.         }
  33.     }
  34.     printf("\n");
  35.  
  36.     for (int i = 0; i < 10; i++) {
  37.         printf("%d ", a[i]);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement