មេរៀនទី១៧: ទាយមនុស្សតាមឈ្មោះ


















C C++
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<ctype.h>
void main()
{    again:
clrscr();
int i,n,num[50],sum=0,j,number;
char ch;
char a[50];
gotoxy(1,1);
printf(“Enter your name:”);
for(i=1;i<=1000;i++)
{
scanf(“%c”,&a[i]);
if(a[i]==10)
break;
}
j=i-1;
for(i=1;i<=j;i++)
{
if(a[i]==’a’||a[i]==’A’||a[i]==’j’||a[i]==’J’||a[i]==’s’||a[i]==’S’)
num[i]=1;
else if(a[i]==’b’||a[i]==’B’||a[i]==’k’||a[i]==’K’||a[i]==’t’||a[i]==’T’)
num[i]=2;
else if(a[i]==’c’||a[i]==’C’||a[i]==’l’||a[i]==’L’||a[i]==’u’||a[i]==’U’)
num[i]=3;
else if(a[i]==’d’||a[i]==’D’||a[i]==’m’||a[i]==’M’||a[i]==’v’||a[i]==’V’)
num[i]=4;
else if(a[i]==’e’||a[i]==’E’||a[i]==’n’||a[i]==’N’||a[i]==’w’||a[i]==’W’)
num[i]=5;
else if(a[i]==’f’||a[i]==’F’||a[i]==’o’||a[i]==’O’||a[i]==’x’||a[i]==’X’)
num[i]=6;
else if(a[i]==’g’||a[i]==’G’||a[i]==’p’||a[i]==’P’||a[i]==’y’||a[i]==’Y’)
num[i]=7;
else if(a[i]==’h’||a[i]==’H’||a[i]==’q’||a[i]==’Q’||a[i]==’z’||a[i]==’Z’)
num[i]=8;
else if(a[i]==’i’||a[i]==’I’||a[i]==’r’||a[i]==’R’)
num[i]=9;
else
num[i]=0;
}
for(i=1;i<=j;i++)
{
sum=sum+num[i];
}
printf(“\nSum=%d”,sum);
if(sum<=9)
number=sum;
else
for(i=1;i<=sum;i++)
{    if(sum-(9*i)>0&&sum-(9*i)<=9)
number=sum-(9*i);
}
printf(”  => Number=%d\n”,number);
if(number==1)
printf(“\n1.ONES\n\nOnes are the most confident and determined of all the numbers.They can do anything when they want to.Ones hate people telling them what to do,but they like telling other people what to do.”);
else if(number==2)
printf(“\n2.TWOS\n\nTwos are kind,shy,thoughtful and polite.They love animals,reading and staying at home.They usually feel really happpy or sad.”);
else if(number==3)
printf(“\n3.THREES\n\nThrees are certainly not lazy.They always do their work on time and still have lots of free time for hobbies.They’re also honest,sensible,reliable and patient with other people.”);
else if(number==4)
printf(“\n4.FOURS\n\nFours are quick and clever,and they can make people laugh.They’re not shy about saying what they think,but people don’t always like what they say.”);
else if(number==5)
printf(“\n5.FIVES\n\nFives are quicker than most people.They’re more intelligent too.They’re interested in lots of different things and are very friendly.They love travel and trying new things.”);
else if(number==6)
printf(“\n6.SIXES\n\nSixes are the happiest and the most optimistic of all the numbers.They find something good even when things are bad.They’ve got lots of friend because they’re so nice.”);
else if(number==7)
printf(“\n7.SEVENS\n\nSevens are clever,serious and quiet,and usually have only one or two close friends.They like being alone.They don’t like noisy crowds and large groups of people.Sevens love animals and the countryside.”);
else if(number==8)
printf(“\n8.EIGTHS\n\nEights are sensible,reliable and nice.In fact, they’re sometimes too kind to other people.They work hard and try hard at their hobbies.”);
else if(number==9)
printf(“\n9.NINES\n\nNines are clever and imaginative,but they’re sometimes lazy.They like having fun,and they are fun to be with.People usually like nines a lot,but nines are not always kind to other people.”);
else
printf(“\nUnkown!”);
printf(“\n\n\nRestart(y/n):”);
again1:
ch=toupper(getch());
if(ch==’Y’)
{       clrscr();
goto again;
}
else if(ch==’N’)
exit(1);
else
goto again1;
getch();
}

//បញ្ចប់