#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
void fun(char a[])
{
char str[100][100];
char temp[200];
int value[200];
int k1=0,k2=0,k3=0;
int i=0,j=0;
while (a[i]!='\0')
{
if (i==0)
{
while (a[i]!=' ')
temp[k3++]=a[i++];
temp[k3]='\0';
k3=0;
strcpy(str[k1],temp);
value[k1++]=1;
}
else
{
if (a[i]==' ')
i++;
while (a[i]!='\0'&&a[i]!=' ')
temp[k3++]=a[i++];
temp[k3]='\0';
k3=0;
j=0;
while (j<k1)
{
if (strcmp(str[j],temp)==0)
{
value[j]+=1;
break;
}
j++;
}
if (j==k1)
{
strcpy(str[k1],temp);
value[k1]=1;
k1++;
}
}
}
cout<<value[1]<<endl;
//cout<<str[0]<<endl;
}
int main()
{
char a[]="aa aa aa aa aa aa aa aa aa aa amedede am am am jnnk adfp crpcwe crwc qa qa qa qa qa qa qa qa qa ";
fun(a);
return 0;
}
#include <string.h>
#include <iostream>
using namespace std;
void fun(char a[])
{
char str[100][100];
char temp[200];
int value[200];
int k1=0,k2=0,k3=0;
int i=0,j=0;
while (a[i]!='\0')
{
if (i==0)
{
while (a[i]!=' ')
temp[k3++]=a[i++];
temp[k3]='\0';
k3=0;
strcpy(str[k1],temp);
value[k1++]=1;
}
else
{
if (a[i]==' ')
i++;
while (a[i]!='\0'&&a[i]!=' ')
temp[k3++]=a[i++];
temp[k3]='\0';
k3=0;
j=0;
while (j<k1)
{
if (strcmp(str[j],temp)==0)
{
value[j]+=1;
break;
}
j++;
}
if (j==k1)
{
strcpy(str[k1],temp);
value[k1]=1;
k1++;
}
}
}
cout<<value[1]<<endl;
//cout<<str[0]<<endl;
}
int main()
{
char a[]="aa aa aa aa aa aa aa aa aa aa amedede am am am jnnk adfp crpcwe crwc qa qa qa qa qa qa qa qa qa ";
fun(a);
return 0;
}