URI Online Judge Solution 1177 Array Fill II Using C, Python Programming Language.
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 x is the number stored in that position.
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 x is the number stored in that position.
Input Sample | Output Sample |
3 | N[0] = 0 |
Solution Using C:
#include <stdio.h>
int main() {
int n,N[1000],i,j=0;
scanf("%d",&n);
for(i=0;i<1000; i++)
{
printf("N[%d] = %d\n",i,j++);
if(j==n)
j=0;
}
return 0;
}
int main() {
int n,N[1000],i,j=0;
scanf("%d",&n);
for(i=0;i<1000; i++)
{
printf("N[%d] = %d\n",i,j++);
if(j==n)
j=0;
}
return 0;
}
Comments
Post a Comment