1177 Array Fill II

Niloy Sarker
By -
0
URI Online Judge | 1177

Array Fill II

Write a program that reads a number T and fill a vector N[1000] with the numbers from 0 to T-1 repeated times, like as the example below.

Input

The input contains an integer number T (2 ≤ T ≤ 50).

Output

For each position of the array N, print "N[i] = x", where i is the array position and is the number stored in that position.
Input SampleOutput Sample
3N[0] = 0
N[1] = 1
N[2] = 2
N[3] = 0
N[4] = 1
N[5] = 2
N[6] = 0
N[7] = 1
N[8] = 2
...
#include <stdio.h>
int main()
{
    int ar[1000], n, i,cnt=0;
    scanf ("%d", &n);
    for(i=0; i<1000; i++)
    {
        printf("N[%d] = %d\n",i,cnt);
        cnt++;
        if(cnt==n)
            cnt=0;
    }
    return 0;
}

Tags:

Post a Comment

0Comments

Post a Comment (0)