-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCPRMT.cpp
More file actions
54 lines (53 loc) · 1.43 KB
/
CPRMT.cpp
File metadata and controls
54 lines (53 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<iostream>
using namespace std;
#include<stdio.h>
#include<string.h>
struct str
{
char m;
int n;
};
int main()
{
str c[2000],temp;
char a[2000],b[2000];
int i,x,j,l1,l2;
while(scanf("%s",a)!=EOF)
{
x=0;
scanf("%s",b);
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l1;i++)
{
for(j=0;j<l2;j++)
{
if(a[i]==b[j])
{
c[x].m=a[i];
c[x].n=c[x].m;
a[i]='$';
b[j]='$';
//cout<<c[x].m<<"\n";
x++;
//cout<<a<<"\n"<<b<<"\n\n";
break;
}
}
}
for(i=0;i<x;i++)
{
for(j=i+1;j<x;j++)
{
if(c[i].n>c[j].n)
{
temp=c[i];
c[i]=c[j];
c[j]=temp;
}
}
cout<<c[i].m;
}
cout<<"\n";
}
}