#include<iostream.h>
#include<conio.h>
#include<string.h>
int mean(char st[],int ls,char s[][],int l[],int n)
{
int i,j,f,flag=0;
for(i=0;(i<n)&&(flag=0);i++)
{
f=1;
if(ls!=l[i])
f=0;
else
{
for(j=0;(j<ls)&&(f=1);j++)
if(st[j]!=s[i][j])
f=0;
}//else
if(f==1)
flag=1;
}//for
if(flag==1)
return 1;
else
return 0;
}
int maximum(char ch[],int lc,int n,char s[][],l[])
{
char str[100];
strcpy(str,char);
int i,m=0;max=0;
for(i=0;i<lc;i++)
{
for(j=i;j<lc-1;j++)
ch[j]=ch[j+1];
ch[l]=0;
lc--;
if(meaning(ch[100],lc,s[100][100],l[100],n)==1)
{
m++;
maximum(ch[100],lc,n,s[100][100],l[100])
}
if(m>max)
max=m;
strcpy(char,str);
}
return max;
}
main()
{
int n,i,j,l[100],max,maximum=0;
char s[100][100];
cout<<"enter n:";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"enter word #"<<i+1<<":";
gets(s[i]);
l[i]=strlen(s[i]);
}
for(i=0;i<n;i++)
{
max=maximum(s[i],l[i],n,s[100][100],l[100]);
if(max>maximum)
{
maximum=max;
j=i;
}
}
cout<<s[j]<<":"<<maximum;
getch();
}//main
#include<iostream.h>
#include<conio.h>
#include<string.h>
main()
{
int i,nopa=0,writer=0,odd,ziro,a[7],s=0,flag=1;
a[1]=0;a[2]=4;a[3]=5;a[4]=8;a[5]=3;a[6]=8;
while(flag=1)
{
odd=0;
ziro=0;
for(i=1;i<=6;i++)
{
if(a[i]%2==1)
odd++;
if(a[i]==0)
ziro++;
}
nopa+=ziro-odd;
writer+=odd-ziro;
if(nopa==writer)
flag=0;
s++;
for(i=6;i>1;i-=2)
{
if(a[i]>9)
a[i-1]+=1;
a[i]%=10;
if(a[i-1]>5)
a[i-2]+=1;
a[i-1]=0;
}
if(h>23)
h=0;
}//while
cout<<s;
getch();
}//main
#include <stdio.h>
#include <conio.h>
int main()
{
int hour=4,min=58,sec=37,nopa,nevisande,zaman=-1;
printf("\nHow many coins does nopa have at start?");
scanf("%d",&nopa);
printf("\nHow many coins does nevisande have at start?");
scanf("%d",&nevisande);
while(nopa!=nevisande)
{
zaman++;
//stepping the clock
sec++;
if(sec==60)
{
sec=0;
min++;
}
if(min==60)
{
min =0;
hour++;
}
if(hour==24)
{
hour = 0;
}
//end of stepping
//nopa gives some coins to nevisande
if(sec%2==1)
{
nopa--;
nevisande++;
}
if((sec/10)%2==1)
{
nopa--;
nevisande++;
}
if(min%2==1)
{
nopa--;
nevisande++;
}
if((min/10)%2==1)
{
nopa--;
nevisande++;
}
if(hour%2==1)
{
nopa--;
nevisande++;
}
if((hour/10)%2==1)
{
nopa--;
nevisande++;
}
//end of nevisande coins
//nevisande gives some coins to nopa
if(sec%10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(sec/10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(min%10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(min/10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(hour%10 == 0)
{
nevisande -=4;
nopa +=4;
}
if(hour/10 == 0)
{
nevisande -=4;
nopa +=4;
}
}//end of while
printf("\nThey would become equal in %d seconds.",zaman);
getch();
return 2010;
}