i can't find what's wrong w/ my program. the output is wrong when i type long names and names w/ less similar letters (sorry for my english i'm a filipino)
#include <stdlib.h>
#include <iostream.h>
#include <string.h>
#include <conio.h>
#include <stdio.h>
char name1[20],name2[20];
int count1[25],count2[25],temp1,temp2,total;
void flames(int num)
{
switch(num)
{
case 1: cout<<"friends";
break;
case 2: cout<<"lovers";
break;
case 3: cout<<"Anger";
break;
case 4: cout<<"Married";
break;
case 5: cout<<"Enemy";
break;
case 6: cout<<"Sweet";
break;
}
}
main()
{
int x,y;
temp1=0;
temp2=0;
cout<<"Sample program: FlAMES"<<endl;
cout<<"--------'------------'------------"<<endl;
cout<<"enter name1 ";
gets(name1);
cout<<"enter name2 ";
gets(name2);
strupr(name1);
strupr(name2);
for(x=0;x<=25;x++)
{
count1[x]=0;
count2[x]=0;
}
for(x=0;x<=20;x++)
{
count1[name1[x]-'A']++;
count2[name2[x]-'A']++;
}
for(x=0;x<=25;x++)
{
if( (count1[x]!=0) && (count2[x]!=0) )
{ temp1=count1[x]+temp1; temp2=count2[x]+temp2;
}
total = temp1+temp2;
}
flames(total%6);endl;
getch();
return 0;
}