Input an array and then print the repeating characters??
Example:
Input:1,3,23,11,44,3,23,2,3.
Output:3,23
plz help me.... i want a code of it. In C language.
Answer Posted / rahulkashyaprajput
package repeatingno;
import java .io.*;
public class Reap
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int no,max=0,n,count=0;
System.out.println("enter no of elements");
no=Integer.parseInt(br.readLine());
int ar[] = new int[no];
System.out.println("enter elements");
for(int i=0;i<no;i++)
ar[i]=Integer.parseInt(br.readLine());
for(int i=0;i<no;i++)
{
if(ar[i]>max)
{
max=ar[i];
}
}
System.out.println("repeated elements are");
for(int i=0;i<=max;i++)
{ for(int j=0;j<no;j++)
{
if(i==ar[j])
count++;
}
if(count>1)
System.out.print(i+" ");
count=0;
}
}
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
Two trains are traveling at 18kmph and are 60 km apart. There is flying in the train. It flies at 80kmph. It flies and hits the second train and then it starts to oscillate between the two trains. At one instance when the two trains colloide it dies. At what distance travel by the fly.
5 women given some of their heights(tall,medium,short)Hair( long, plainted),stards(Black or Brown), sari,2 medium,2-short.Tall-no sari.Plainted-medium.Answer the combinations.
A person starts walking at a speed of 5km/hr through half the distance, rest of the distance he covers with a speed 4km/hr. Total time of travel is 9 hours. What is the maximum distance he can cover?
There are 9 coins. One of 9 is less weighted and others have equal weighed. Find the minimum no of balances to find the defective coin?
a student is ranked 13th from right and 8th from left.how many are there(similar)
A car is filled with four and half gallons of oil for full round trip. Fuel is taken 1/4 gallons mor3 in going than coming. What is the fuel consumed in coming up?
A building with hight D ft shadow upto G A neighbour building with what height shadow C ft is?
How many 3-digit numbers with atleast one 5 in their digits?
if the word 'ddosszm' is changed to 'central' then what will be the change for 'rtjbl' ?
A person has Rs 100/- in his pocket, he can as 25 pencils or 15books. He kept 15% of the money for travelling expenses and purchased 5 ncils.So how many books he can purchase with the remaining money.
How is the father of the man ,who is the brother of the only aunt of my brother related to me?
On Monday a manufacturer processed a batch of bats, on Tuesday he processed three times as many, and on Wednesday he processed 4000 bats. In the three days, He processed 16000 bats. How many did he process on Tuesday?
If A=Z, B=Y, C=X, .......... Z=A, Then POCKET = ?
Rahul took a part in cycling game where 1/5 ahead of him and 5/6 behind him then total number of participants?
Two distinct no's are taken from 1,2,3,4......28. Find the probability that their sum is less than 13