المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : حرك اسمك اينما تريد في شاشة سي بلس بلس


معتصم بكري
03-11-2008, 10:45 AM
السلام عليم
هذا برنامج صغير يجب على كل طالب سنة أولى أن يفهمه جيداً
ومن أجل ذللك وضعت تعليقات بجانب كل سطر
و إذا لم يتم فهم الكود مع أنهي أجده بسيط فقط أريد من الأخوة رد من أجل شرح
أي سطر أو حتى الكود كله أو في المعهد
#include<iostream.h>
#include<conio.h> //this to use "getch()"
#include<windows.h> //this to use "system()"
void welcome();
void main()
{
welcome(); //this function just to show message
char name[20]; //this Variable to save your sentence
char test=0; //this Variable to decide where you will move your sentence
cout<<"Enter you sentence"<<endl;
cin.get(name,20); //the sentence to ignore space and take sentece contain space
system("cls"); //this to erase screen and this use in DOS
int col=10,row=10 ; //this to decide how many rows and cols will move
do
{

for( int i=0 ; i <col ; i++) //this loop for Cols
cout<<'\n';
for(int j=0 ; j<row ; j++) //this loop for Rows
cout<<' ';
cout<<name<<endl;

do
{
test=getch(); //this to take just one Character form keyboard
if( test =='e' || test == 'E' ) //this to end program when you enter e or E
break;
}while(test < '1' && test > '9' );

if( test == '4') // this to control the row
row--;
else if( test == '6')
row++;
else if( test == '8') // this to control the col
col--;
else if( test == '2')
col++;
else if( test == '9')
{ col-- ; row++; }
else if( test == '7')
{ col-- ; row--; }
else if( test == '3')
{ col++ ; row++; }
else if( test == '1')
{ col++ ; row--; }
system("cls");

}while(test !='e' && test != 'E');
}
void welcome()
{
cout<<"Welcome to in my small game"<<endl;
cout<<"\nNote: to use this game press 1,2,3,4,6,7,8,9"<<endl;
cout<<"\n\tTo END program just Press e"<<endl;
cout<<"\n\tPress Enter To Continue\n\n"<<endl;
getch();
system("cls");
}

SYR_SNIPER
03-11-2008, 03:36 PM
^^ برنامج حلو ورائع وجميل وكل شي ;)
عجبني والحمد لله فهمتو وتسلم

mss cool
03-11-2008, 05:16 PM
يعطيك العافية أخي معتصم
الكود مرتب كتير وحلو ومفهوم
بتمنى لك التوفيق

D@RE DEVIL
03-12-2008, 11:47 AM
THANK YOU VERY MUCH MOATASEM