Computer Science, asked by robertoflorin610, 7 months ago

Write a C / C ++ program that reads from the keyboard two natural numbers in the range [2,20], n and k, and construct in memory a two-dimensional array with n rows and n ∙ k columns, numbered starting with 1, so that each line i (i∈ [1, n]) stores an increasing string of terms with the property that the first term is i, each value appears in a string of exactly k times and any two adjacent terms have values equal or consecutive.

EXAMPLE: n=4, k=3
1 1 1 2 2 2 3 3 3 4 4 4
2 2 2 3 3 3 4 4 4 5 5 5
3 3 3 4 4 4 5 5 5 6 6 6
4 4 4 5 5 5 6 6 6 7 7 7

Answers

Answered by rk84678010
0

Answer:

sorry!! i don't know the answer

Answered by zinc916
0

Answer:

int main()

{

int n,k,x,t,x,i,j,a[22][22]={0};

scanf("%d %d",&n,&k);

t=1;

for(i=0;i<n;i++)

{ x=i+1;

for(j=1;j<=k*n;j++)

{

a[i][j-1]=x;

printf("%d ",a[I][j]);

if(j%k==0)

x++;

}

printf("\n");

}

}

Similar questions