aboutsummaryrefslogtreecommitdiffstats
path: root/make_heavy.c
blob: 6961a31d571ca26d6d48cebb17a2ef6e2a047436 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define MAX_DIGITS 3000
#define MIN_DIGITS 100
#define VARIATION 100


int main()
{

	size_t size;
	size_t i,j;
	size_t sz;
	size_t heavy_line;
	char *number;//we don't want a stack overflow so it goes on the heap


	scanf("%zu",&size);
	scanf("%zu",&heavy_line);


	number = malloc(sizeof(char)*(MAX_DIGITS+10+VARIATION));
	if(number==NULL)return -1;
	srand(time(NULL));
	printf("%zu\n",size);

	for(i=0;i<heavy_line && i<size;++i)
	{
		for(j=0;j<size;++j)
		{
			for(sz=MIN_DIGITS,number[sz+1]='\0'; sz>0 ;number[sz]=rand()%10+'0',--sz);
			number[0]=rand()%9 + '1';
			printf("%s ",number);
		}
		printf("\n");
	}

	if(heavy_line<size)
	{
		for(j=0;j<size;++j)
		{
			
			for(sz=(MAX_DIGITS-(rand()%(VARIATION+1))),number[sz+1]='\0'; sz>0 ;number[sz]=rand()%10+'0',--sz);
			number[0]=rand()%9 + '1';
			printf("%s ",number);
		}
		printf("\n");
	}

	for(++i;i<size;++i)
	{
		for(j=0;j<size;++j)
		{
			for(sz=MIN_DIGITS,number[sz+1]='\0'; sz>0 ;number[sz]=rand()%10+'0',--sz);
			number[0]=rand()%9 + '1';
			printf("%s ",number);
		}
		printf("\n");
	}
	return 0;
}