Write a program that will read in a list of numbers and will then print out the same list except numbers that have already been printed will be printed as a zero instead.
Input Format:
Input consists of n+1 integers where n is the number of elements in the list. The first integer corresponds to n. The remaining n integers correspond to the elements in the list.
Assume that the maximum value of n is 100.
Output Format:
Output consists of n integers on separate lines.
Sample Input :
5
2
3
4
3
6
Sample Output:
2
3
4
6
Code:
#include<stdio.h>
int main(){
int n,a[100],i,c,j;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
c=0;
for(j=0;j<i;j++)
{
if(a[i]==a[j]){
c=1;
break;
}
}
if(c==1)
printf("0\n");
else
printf("%d\n",a[i]);
}
return 0;
}
No comments:
Post a Comment