forked from PraveenMohan13/BASIC-50
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString Anagram
More file actions
42 lines (42 loc) · 692 Bytes
/
String Anagram
File metadata and controls
42 lines (42 loc) · 692 Bytes
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
#include<stdio.h>
#include<string.h>
int fun(char a[],int l)
{
for(int i=0;i<l-1;i++)
{
for(int j=i+1;j<l;j++)
{
if(a[i]>a[j])
{
int t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
}
int main() {
int f=0;
char a[10],b[10];
scanf("%s",a);
scanf("%s",b);
int l1=strlen(a);
int l2=strlen(b);
if(l1!=l2)
{
printf("not an anagram");
return 0;
}
fun(a,l1);
fun(b,l2);
for(int i=0;i<l2;i++)
{
if(a[i]!=b[i])
f=1;
}
if(f==0)
printf("anagram");
else
printf("not an anagram");
return 0;
}