Advertisement
Guest User

Untitled

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