ok..so i wanted to make a program in C that is similar to the game FLAMES...for those who don't know the game: it's where you input 2 names and then the computer will then cancel the similar letter i name1 and in name2..(e.g. name1:marie yu name2:mark cruz.....2 m's will be cancelled, 2 a, 3 r's, ad 2 u's.....)then it will print the total nos. of canceled letters...
pls. guys help me..i need the entire C program, not just a detail of it..and pls. don't tell me to do my own homework or what because i try to do it myself but my knowledge in C programming is not that high..i try this many times but i can't do it.
Pls. help in C programming?
/*programmer name:Ahmed Moustafa*/
/*Electronics and Communication student at AAST in Alexandria in Egypt*/
/*copy and paste this code and programme will run correctly*/
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
#include%26lt;string.h%26gt;
void main()
{
char str1[50],str2[50],c;
int num[50],total=0,i,j;
printf("Enter the first name ");
gets(str1);
printf("Enter the second name ");
gets(str2);
for(i=0;i%26lt;strlen(str1);i++)
{
c=str1[i];
num[i]=0;
for(j=0;j%26lt;strlen(str2);j++)
if(c==str2[j])
{
str2[j]=' ';
num[i]++;
if(c==' ')
num[i]--;
}
if(num[i]%26gt;0)
for(j=0;j%26lt;strlen(str1);j++)
if(c==str1[j])
{
str1[j]=' ';
num[i]++;
total=total+num[i];
}
}
if(total%26gt;0)
printf("The two names are changed to\n%s\n%s\nthe number of chacters changed is %d",str1,str2,total);
else
printf("No change");
getch();
}
Reply:Did u ask ur professor?
Reply:just i ll give some logic u try it out..
let the strings be name1[ ] and name2[ ]
int count = 0;
for(int i=0; i%26lt;length of name1;i++)
{
fot(int j;j%26lt;length of name2;j++)
{
if(name1[i] == name2[j])
{
count++;
break;
}
}
}
i think you can do easily using this..
all the best
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment