forked from Vishal-Aggarwal0305/DSA-CODE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
countwords.cpp
45 lines (42 loc) · 857 Bytes
/
countwords.cpp
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
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int counnt,i,x,y,n,t,r;
char a[10][25];
cout<<"Enter the number of names you want to enter"<<endl;
cin>>n;
cout<<"Enter the names"<<endl;
for(i=0;i<n;i++)
{
cin.getline(a[i],25);
if(a[i][0] < 65 || (a[i][0] > 90 && a[i][0] <97) || a[i][0] > 122)
i--;
}
for(x=0;x<n;x++)
{
counnt=0;
for(y=0;y<n;y++)
{
if(strlen(a[x])==strlen(a[y]))
{
r=0;
for(t=0;t<strlen(a[x]);t++)
{
if(a[x][t]!=a[y][t])
{
r=1;
break;
}
}
if(r==0)
{
counnt++;
}
}
}
cout<<a[x]<<" "<<counnt<<" ";
}
return 0;
}