Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale.h>
- int main()
- {
- int a[10], i, max, k=0;
- printf("GENERATION ARRAY\n");
- for (i = 0; i < 10; i++) {
- a[i] = rand() % 10 + 1;
- printf("%d \n", a[i]);
- }
- max = a[0];
- for (i = 0; i < 10; i++) {
- if (max < a[i])
- {
- max = a[i];
- k = i;
- }
- }
- for ( i = k-1; i >= 0; i--)
- {
- if (a[i] > 0) {
- a[i] = -1;
- break;
- }
- }
- for (i = 0; i < 10; i++) {
- if (a[i] != -1)
- {
- printf("res array: %d \n", a[i]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement