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 / amit kumar mehta
#include<iostream>
using namespace std;
int main() {
int a[] = {1,3,23,11,44,3,23,2,3};
// for ( i = 0; i < 10; ++i) {
// cin >> a[i];
// }
for ( int i = 0; i < 9 ; i++) {
int count = 0;
for (int j = i+1; j < 9; j++) {
if (a[i] == a[j]) {
count++;
}
}
if (count > 0) {
int temp[10];
int rep = 0;
for (int m = 0; m < 10; ++m) {
if (a[i] == temp[m]) {
rep++;
}
}
if (rep <= 0) {
cout << a[i] << " ";
temp [i] = a[i];
}
}
}
return 0;
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
A and B decide to speak truth or lie on a day. Another person asks A if he is saying truth or lie. B listens to A whatever he answers. Now the person asks B what A had told. B replies as " A has told that he is a liar". What does B say?
The square of a two digit number is divided by half the number. After 36 is added to the quotient, this sum is then divided by 2. The digits of the resulting number are the same as those in the original number, but they are in reverse order. The ten's place of the original number is equal to twice the difference between its digits. What is the number?
A lorry starts from Banglore to Mysore at 6.00 A.M,7.00am.8.00 am.....10 pm. Similarly one another starts from Mysore to Banglore at 6.00 am,7.00 am, 8.00 am.....10.00pm. A lorry takes 9 hours to travel from Banglore to Mysore and vice versa. A lorry which has started at 6.00 am will cross how many lorries.
any body send me the sample paper for pnb dy.managers,to ravitejareddy.r@gmail.com
A works thrice as much as B. If A takes 60 days less than B to do a work then find the number of days it would take to complete the work if both work together?
k, l are men who take home a salary of x, y respectively.the total amount taken home is
A soldier looses his way in a thick jungle at random walks from his camp but mathematically in an interesting fashion. First he walks one mile east then half mile to north. Then 1/4 mile to west, then 1/8 mile to south and so on making a loop. Finally hoe far he is from his camp and in which direction.
A mother is 30 years older than her daughter however she will be only thrice as old as the daughter after 5 years. What is mother’s present age ?
Ram starts from A walking 2 km North and turns right and walks 4 km and turns right again and walks 4 km and turns right again and walks 4 km and meets Radha at Bwalking in the opposite direction to Ram . Which direction does Ram walk after the first turn?
if 2x-y=4 then 6x-y is
A moves 3 kms east from his starting point . He then travels 5 kms north. From that point he moves 8 kms to the east.How far is A from his starting point?
f(X)= 2X-1 + f(X-1) if X is not equal to zeroandiff(X=0)=0, If f(X)-f(X-1)=f(X-8) for X>5 then X= ?
Some work is done by two people in 24 minutes. One of them can do this work alone in 40 minutes. How much time does the second person take to do the same work ?
SEND + MORE = MONEY. Then what is the value of M + O + N + E + Y ?
hi...i have got selected for United bank po interview.can anyboby suggest me how to prepare for interview.r there any books for po interview?i am asking because..this s my 1 st bank interview...pls send me interview material if u have any ..my mail id=pruthi_tarun@yahoo.co.in....thank u