Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <limits.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- int main(void) {
- freopen("output.txt", "w", stdout);
- srand(time(NULL));
- int n, m, a, minV = INT_MAX;
- int i, j;
- char ans[100] = "";
- char buf[10];
- n = rand() % 30 + 1;
- int* u = (int*)malloc(n*sizeof(int));
- for(i = 0; i < n; i++)
- u[i] = 0;
- for(i = 0; i < n; i++) {
- m = rand() % 20 + 1;
- for(j = 0; j < m; j++) {
- a = rand()-INT_MAX/2;
- printf("%d ", a);
- if(a < minV) {
- u[i] = 1;
- minV = a;
- sprintf(buf, "%d", i+1);
- strcpy(ans, buf);
- strcat(ans, " ");
- } else if(a == minV) {
- if(!u[i]) {
- u[i] = 1;
- sprintf(buf, "%d", i+1);
- strcat(ans, buf);
- strcat(ans, " ");
- }
- }
- }
- printf("\n");
- }
- printf("%s", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement