برنامه نویسی
#include
#include
#include
#include
#include
#include
#include

int    driver=DETECT,mode=0;
char   p[8]={1};
const int max=10;
struct travel {//struct for information, register,report,
 char name[20];//name
       char lname[40];//famil
       char fname[20];//name pedar
       char ss[10];//shomare shenasname
       char tt[10];//tarikh tavalod
       char sf[20];//shomare fish
       char phone[20];//shomare telephon
       char address[200];//address
       };

       struct travel pp[max];
       FILE *in,*out,*in2,*out2;
void gozinemenu(); //option main menu
int    dis();//display main backgrouand
int    rec(int co,int sx,int sy,int ex,int ey);//drawing rectangle
void harakatemenubala();
void noo_kar(int sx);
void sabtenam();
int findfree();
void list440();
void switch440(int sy);
void list340();
void switch340(int sy);
void d();
void t();
void   main()//main program
{
     dis();
     harakatemenubala();


}


//*******************************************
int rec(int co,int sx,int sy,int ex,int ey)
{
      setcolor(co);
      rectangle(sx,sy,ex,ey);
      setfillpattern(p,co);
      setfillstyle(1,co);
       floodfill(sx+1,sy+1,co);
       return sx,sy,ex,ey;
}
//****************************
int dis()
{
initgraph(&driver,&mode,"c:\borlandc\bin");
    setbkcolor(9);
    setcolor(3);
    rectangle(0,0,639,20);
    setfillpattern(p,3);
    setfillstyle(1,3);
    floodfill(5,5,3);

    setcolor(15);
    rectangle(1,23,638,400);
    rectangle(2,24,637,399);
    line(200,25,200,399);
    line(202,25,202,399);

    setcolor(11);
    rectangle(0,402,639,450);
    setfillpattern(p,11);
    setfillstyle(1,11);
    floodfill(2,404,11);

    setcolor(3);
    rectangle(0,452,639,479);
    setfillpattern(p,3);
    setfillstyle(1,3);
    floodfill(1,453,3);
    gozinemenu();

    int s[]={0,20,0,0,200,0,240,20};
    setcolor(15);
    fillpoly(4,s);
    setfillpattern(p,15);
    setfillstyle(1,15);
    floodfill(5,5,15);

    setcolor(4);
    circle(10,10,10);
    setfillpattern(p,4);
    setfillstyle(1,4);
    floodfill(5,5,4);

     setcolor(10);
    circle(30,10,10);
    setfillpattern(p,10);
    setfillstyle(1,10);
    floodfill(31,5,10);

     setcolor(1);
    circle(50,10,10);
    setfillpattern(p,1);
    setfillstyle(1,1);
    floodfill(51,5,1);
    setcolor(8);
    outtextxy(5,10,"M.H. A B R A R I");

      return 0;
      }
//-----------------
void gozinemenu()
{
 setcolor(4);
 outtextxy(540,10," ô‘÷ –“™");
 outtextxy(440,10," ¤¥“");
 outtextxy(340,10," ©¤¥ð");
 outtextxy(240,10,"ù¤‘“¤¢");
       // outtextxy(140,10," 𸤡");
}
//-------------------
void harakatemenubala()
{
  int sx=540,sy=0,ex=640,ey=20;
  int x;
  for(;;){
  x=getch();
  switch (x){
    case 75: //key for move left
   rec(3,sx,sy,ex,ey);
   sx-=100;
   ex-=100;
   if(sx>=240)
   rec(10,sx,sy,ex,ey);
   else{
   sx=540;
   ex=640;
   rec(10,sx,sy,ex,ey);  }
   gozinemenu();
   switch (sx){
    case 540:
       setcolor(3);
       outtextxy(200,460," ....... ù¢÷÷î ùþú—ø¤¥ê ô¤÷  ù¤‘“¤¢");
       setcolor(15);
       outtextxy(300,460," –‘ä‘ó¯ ¢ø¤ø");
       break;
    case 440:
    setcolor(3);
       outtextxy(300,460," –‘ä‘ó¯ ¢ø¤ø");
         setcolor(15);
       outtextxy(200,460," .....ø 食ø ü“‘þ¥‘“ø ù¤þ¡£  ü¤“ ¤¥“ ");
       break;
    case 340:
       setcolor(3);
       outtextxy(200,460," .....ø 食ø ü“‘þ¥‘“ø ù¤þ¡£  ü¤“ ¤¥“ ");
        setcolor(15);
       outtextxy(200,460," ..... ü꣟ø üꐤ¬÷ –¨þó‘®ä –¨þó ©þ‘õ÷");
       break;
    case 240:
    setcolor(3);
       outtextxy(200,460," ..... ü꣟ø üꐤ¬÷ –¨þó‘®ä –¨þó ©þ‘õ÷");
        setcolor(15);
       outtextxy(200,460," ....... ù¢÷÷î ùþú—ø¤¥ê ô¤÷  ù¤‘“¤¢");
       break;
       }
   noo_kar(sx);
   break;
      case 77: //key for move right
   rec(3,sx,sy,ex,ey);
   sx+=100;
   ex+=100;
   if(sx<=540)
   rec(10,sx,sy,ex,ey);
   else{
   sx=240;
   ex=340;
   rec(10,sx,sy,ex,ey);}
   gozinemenu();
        switch (sx){
    case 540:
       setcolor(3);
       outtextxy(200,460," .....ø 食ø ü“‘þ¥‘“ø ù¤þ¡£  ü¤“ ¤¥“ ");

       setcolor(15);
       outtextxy(300,460," –‘ä‘ó¯ ¢ø¤ø");
       break;
    case 440:
          setcolor(3);
       outtextxy(200,460," ..... ü꣟ø üꐤ¬÷ –¨þó‘®ä –¨þó ©þ‘õ÷");

       setcolor(15);
       outtextxy(200,460," .....ø 食ø ü“‘þ¥‘“ø ù¤þ¡£  ü¤“ ¤¥“ ");
       break;
    case 340:
        setcolor(3);
       outtextxy(200,460," ....... ù¢÷÷î ùþú—ø¤¥ê ô¤÷  ù¤‘“¤¢");

        setcolor(15);
       outtextxy(200,460," ..... ü꣟ø üꐤ¬÷ –¨þó‘®ä –¨þó ©þ‘õ÷");
       break;
    case 240:
         setcolor(3);
       outtextxy(300,460," –‘ä‘ó¯ ¢ø¤ø");

        setcolor(15);
       outtextxy(200,460," ....... ù¢÷÷î ùþú—ø¤¥ê ô¤÷  ù¤‘“¤¢");
       break;
       }

   noo_kar(sx);
   break;
      case 27: //key for exit program
    rec(14,240,200,440,250);
    setcolor(4);
    outtextxy(245,225,"  ¢þøª 𤑡 ¢þóþ‘õ ‘þ");
    int s=getch();
    if(s==13)
    goto exit;
    else
    rec(9,240,200,440,250);
   }//end switch
    continue;
    exit:break;
   }//end for
}//end main
//----------------------------------
void noo_kar(int sx)
{
     int e1,e2,sy,ex,ey;
    e1=getch();
    if(e1==13)
  switch(sx){
 case 540: //case for base information
   setcolor(3);
   outtextxy(300,460," –‘ä‘ó¯ ¢ø¤ø");

    sabtenam();
    break;//end case 540 'base information'
 case 440: //case for register
     setcolor(3);
     outtextxy(200,460," .....ø 食ø ü“‘þ¥‘“ø ù¤þ¡£  ü¤“ ¤¥“ ");

     rec(5,435,25,535,165);
     rec(14,440,30,540,170);
     list440();
   sy=30;
   ey=50;
   sx=440;
   ex=540;
   for(;;){

   e2=getch();
   switch (e2){
   case 80:
     rec(14,sx,sy,ex,ey);
     sy+=20;
     ey+=20;
     if(sy<=150)
     rec(12,sx,sy,ex,ey);
     else{
     sy=30;
     ey=50;
     rec(12,sx,sy,ex,ey);}
     list440();
     switch440(sy);
     break;
   case 72:
     rec(14,sx,sy,ex,ey);
     sy-=20;
     ey-=20;
     if(sy>=30)
     rec(12,sx,sy,ex,ey);
     else{
     sy=150;
     ey=170;
     rec(12,sx,sy,ex,ey);}
     list440();
     switch440(sy);
     break;
        case 27:
      rec(9,435,25,540,170);
      goto exit2;
      }//end switch
        }// end for
   exit2:break;

    //end case 440 for 'rtegister'
 case 340: //case for report
    setcolor(3);
    outtextxy(200,460," ..... ü꣟ø üꐤ¬÷ –¨þó‘®ä –¨þó ©þ‘õ÷");


   rec(5,335,25,435,125);
   rec(14,340,30,440,130);
    list340();
   sy=30;
   ey=50;
   sx=340;
   ex=440;
   for(;;){

   e2=getch();
   switch (e2){
   case 80:
     rec(14,sx,sy,ex,ey);
     sy+=20;
     ey+=20;
     if(sy<=110)
     rec(12,sx,sy,ex,ey);
     else{
     sy=30;
     ey=50;
     rec(12,sx,sy,ex,ey);}
     list340();
     switch340(sy);
     break;
   case 72:
     rec(14,sx,sy,ex,ey);
     sy-=20;
     ey-=20;
     if(sy>=30)
     rec(12,sx,sy,ex,ey);
     else{
     sy=110;
     ey=130;
     rec(12,sx,sy,ex,ey);}
     list340();
     switch340(sy);
     break;
        case 27:
      rec(9,335,25,440,133);
      goto exit;
      }//end switch
        }// end for
   exit:break;
   //end case 340 for 'report'.
   case 240:
    setcolor(3);
    outtextxy(200,460," ....... ù¢÷÷î ùþú—ø¤¥ê ô¤÷  ù¤‘“¤¢");
    for(;;){
    rec(1,5,25,635,395);
    int q;
    q=getch();
    if(q==27){
        rec(9,5,25,635,395);
   setcolor(15);
      line(200,25,200,399);
      line(202,25,202,399);

      break; }   }
   } //end switch
} //end function typetravel
//----------------------------------------
void sabtenam()
{
 int x2;
   for(;;){
   setcolor(4);
   outtextxy(300,460,"....... öþ¤ê‘¨õ –‘ä‘ó¯ –ê‘þ¤¢");
   rec(1,210,25,635,395);
   setcolor(15);
   line(495,30,495,260);
   outtextxy(500,35," :ô‘÷");
   line(210,50,630,50);
   outtextxy(500,65," :üð¢ø÷‘¡ô‘÷");
   line(210,80,630,80);
   outtextxy(500,95," :¤¢• ô‘÷");
   line(210,110,630,110);
   outtextxy(500,125," :ùõ‘÷¨‘÷ªù¤‘õª");
   line(210,140,630,140);
   outtextxy(500,155," :¢óø—  þ¤‘—");
   line(210,170,630,170);
   outtextxy(500,185," :©þê ù¤‘õª");
   line(210,200,630,200);
   outtextxy(500,215," :öêó—");
   line(210,230,630,230);
   outtextxy(500,245," :§¤¢");
   line(210,260,630,260);
   x2=getch();
    if(x2==69)
     continue;
     if(x2==27) {
    rec(9,210,25,635,395);
    setcolor(3);
        outtextxy(300,460,"....... öþ¤ê‘¨õ –‘ä‘ó¯ –ê‘þ¤¢");
    break; }
   int t;
   t=findfree();
   in=fopen("a:infos","a+b");
   if(!in)

   outtextxy(220,300,"not open");
   gotoxy(30,5);
   gets(pp[t].name);
   gotoxy(30,9);
   gets(pp[t].lname);
   gotoxy(30,13);
   gets(pp[t].fname);
   gotoxy(30,17);
   gets(pp[t].ss);
   gotoxy(30,20);
   gets(pp[t].tt);
   gotoxy(30,23);
   gets(pp[t].sf);
   gotoxy(30,27);
   gets(pp[t].phone);
   gotoxy(30,31);
   gets(pp[t].address);

   fwrite(&pp[0],sizeof(struct travel),8,in);
   fclose(in);


      }//end for
} //end function sabtename
//------------------------------------------------
int findfree()
{  int r,i;
   in=fopen("a:infos","a+b");
   for(i=0;i      {fread(&pp[i],sizeof(struct travel),8,in);
      if(pp[i].name[0]=='\0')
  return i; }
  return -1;

}//end funfind free
//------------------------------------------
void list440()
{
   setcolor(4);
   outtextxy(450,40,"–¨þ¤");
   outtextxy(450,60,"ö‘“þ—ª•");
   outtextxy(450,80,"ü“‘þ¥‘“");
   outtextxy(450,100,"ø›—¨›");
    outtextxy(450,120," 食");

}//end fun
//---------------------------
void switch440(int sy)
{
    int r;
    r=getch();
    if(r==13)
    switch(sy){
       case 30:int j;
      setcolor(4);
      outtextxy(400,460,"....... ö¢ª –¨þ¤ ñ‘Ÿ ¤¢");
      remove("a:infos");
      for(j=0;j       pp[j].name[0]='\0';
        setcolor(3);
      outtextxy(400,460,"....... ö¢ª –¨þ¤ ñ‘Ÿ ¤¢");

   //    rec(9,435,25,540,170);
      break;
       case 50:
   int k;
      setcolor(4);
      outtextxy(300,460,"a:\ backup....... ö‘“þ—ª• ñþ‘ê ¢‘›þ");
      in=fopen("a:infos","a+b");
      for(k=0;k      fread(&pp[k],sizeof(struct travel),8,in);
      fclose(in);
      out=fopen("a:backup","a+b");
      for(k=0;k      fwrite(&pp[k],sizeof(struct travel),8,out);
      fclose(out);
   //   rec(9,435,25,540,170);
   setcolor(3);
      outtextxy(300,460,"a:\ backup....... ö‘“þ—ª• ñþ‘ê ¢‘›þ");

      break;
       case 70:
       //rec(9,435,25,540,170);
     setcolor(4);
     outtextxy(300,460,"...... –‘ä‘ó¯ ü“‘þ¥‘“");

     in=fopen("a:infos","a+b");
     for(int i=0;i       fread(&pp[i],sizeof(struct travel),8,in);
       fclose(in);
     setcolor(3);
     outtextxy(300,460,"...... –‘ä‘ó¯ ü“‘þ¥‘“");
    break;
     case 90:
   setcolor(4);
     outtextxy(300,460,"...... ø›—¨› ñ‘Ÿ¤¢");
     in=fopen("a:infos","a+b");
     for( i=0;i       fread(&pp[i],sizeof(struct travel),8,in);
       fclose(in);
       rec(9,435,25,540,170);
       rec(1,210,30,635,395);

      int w;
      cin>>w;
      for(i=0;i      if(w==i)  {

   setcolor(15);
   line(495,30,495,260);
   outtextxy(500,35," :ô‘÷");
   line(210,50,630,50);
   outtextxy(500,65," :üð¢ø÷‘¡ô‘÷");
   line(210,80,630,80);
   outtextxy(500,95," :¤¢• ô‘÷");
   line(210,110,630,110);
   outtextxy(500,125," :ùõ‘÷¨‘÷ªù¤‘õª");
   line(210,140,630,140);
   outtextxy(500,155," :¢óø—  þ¤‘—");
   line(210,170,630,170);
   outtextxy(500,185," :©þê ù¤‘õª");
   line(210,200,630,200);
   outtextxy(500,215," :öêó—");
   line(210,230,630,230);
   outtextxy(500,245," :§¤¢");
   line(210,260,630,260);

   outtextxy(220,35,pp[i].name);
   outtextxy(220,65,pp[i].lname);
   outtextxy(220,95,pp[i].fname);
   outtextxy(220,125,pp[i].ss);
   outtextxy(220,155,pp[i].tt);
   outtextxy(220,185,pp[i].sf);
   outtextxy(220,215,pp[i].phone);
   outtextxy(220,245,pp[i].address); }
    int a;
    a=getch();
    if(a==27){
  rec(9,210,30,635,395);
  goto exit;}
    //end for
    exit: setcolor(3);
     outtextxy(300,460,"...... ø›—¨› ñ‘Ÿ¤¢");
   break;
    case 110:
     setcolor(4);
     outtextxy(300,460,"......  食 ñ‘Ÿ¤¢");
       rec(9,435,25,540,170);
       setcolor(4);
       outtextxy(300,410,"¢þ÷î ¢¤ø ¤ éþ¢¤ ù¤‘õª");
       int n;
       cin>>n;
     in=fopen("a:infos","a+b");
     for( i=0;i       fread(&pp[i],sizeof(struct travel),8,in);
      if(i==n) {
       pp[i].name[0]='\0';
       in2=fopen("a:del","a+b");
       fwrite(&pp[i],sizeof(struct travel),8,in2);
       fclose(in2);
        fwrite(&pp[i],sizeof(struct travel),8,in);
        fclose(in);    }}
       setcolor(11);
       outtextxy(300,410,"¢þ÷î ¢¤ø ¤ éþ¢¤ ù¤‘õª");
       setcolor(3);
       outtextxy(300,460,"......  食 ñ‘Ÿ¤¢");

       break;
       }//end switch

}//end fun switch440.
//---------------
void list340()
{
   setcolor(4);
   outtextxy(350,40,"–¨þó");
   outtextxy(350,60,"ü꣟");
   outtextxy(350,80,"üꐤ¬÷");

}//end fun
//-------------------------
void switch340(int sy)
{
int r;
r=getch();
if(r==13)
switch(sy){
       case 30:
        setcolor(4);
        outtextxy(300,460,"...... ü¢ø¤ø –¨þó");
        in=fopen("a:infos","a+b");
      for(int k=0;k      fread(&pp[k],sizeof(struct travel),8,in);
      fclose(in);

     for(;;){
     rec(1,5,25,635,395);
     setcolor(15);
     line(5,70,635,70);
     line(5,100,635,100);
     line(5,130,635,130);
     line(5,160,635,160);
     line(5,190,635,190);
     line(5,220,635,220);
     line(5,250,635,250);
     line(5,280,635,280);
     line(5,310,635,310);
     line(5,340,635,340);
     line(5,370,635,370);
     line(600,25,600,395);
     line(500,25,500,395);
     line(400,25,400,395);
     line(300,25,300,395);
     line(200,25,200,395);
     line(100,25,100,395);

     outtextxy(510,50,"ô‘÷");
     outtextxy(410,50,"ñþõ‘ê");
     outtextxy(310,50,"¤¢• ô‘÷");
     outtextxy(210,50,"ùõ‘÷¨‘÷ª");
     outtextxy(110,50,"¢óø—  þ¤‘—");
     outtextxy(10,50," öêó—");
      int d=55;
     for(k=0;k     if(pp[k].name[0]!='\0'){
     d+=30;
     outtextxy(510,d,pp[k].name);
     outtextxy(410,d,pp[k].lname);
     outtextxy(310,d,pp[k].fname);
     outtextxy(210,d,pp[k].ss);
     outtextxy(110,d,pp[k].tt);
     outtextxy(10,d,pp[k].phone);}
     int x;
     x=getch();
     if(x==27) {
      setcolor(3);
        outtextxy(300,460,"...... ü¢ø¤ø –¨þó");
      rec(9,5,25,635,395);
      setcolor(15);
      line(200,25,200,399);
      line(202,25,202,399);
      goto exit;}
     }//end for
       exit: break;
       case 50:
  setcolor(4);
        outtextxy(300,460,"......  ü꣟ –¨þó");
        in2=fopen("a:del","a+b");
      for( k=0;k      fread(&pp[k],sizeof(struct travel),8,in2);
      fclose(in);

                    for(;;){
     rec(1,5,25,635,395);
     setcolor(15);
     line(5,70,635,70);
     line(5,100,635,100);
     line(5,130,635,130);
     line(5,160,635,160);
     line(5,190,635,190);
     line(5,220,635,220);
     line(5,250,635,250);
     line(5,280,635,280);
     line(5,310,635,310);
     line(5,340,635,340);
     line(5,370,635,370);
     line(600,25,600,395);
     line(500,25,500,395);
     line(400,25,400,395);
     line(300,25,300,395);
     line(200,25,200,395);
     line(100,25,100,395);

     outtextxy(510,50,"ô‘÷");
     outtextxy(410,50,"ñþõ‘ê");
     outtextxy(310,50,"¤¢• ô‘÷");
     outtextxy(210,50,"ùõ‘÷¨‘÷ª");
     outtextxy(110,50,"¢óø—  þ¤‘—");
     outtextxy(10,50," öêó—");
      int d=55;
     for(k=0;k //    if(pp[k].name[0]!='\0'){
     d+=30;
     outtextxy(510,d,pp[k].name);
     outtextxy(410,d,pp[k].lname);
     outtextxy(310,d,pp[k].fname);
     outtextxy(210,d,pp[k].ss);
     outtextxy(110,d,pp[k].tt);
     outtextxy(10,d,pp[k].phone);}
     int x;
     x=getch();
     if(x==27) {
      setcolor(3);
        outtextxy(300,460,"......  ü꣟ –¨þó");
      rec(9,5,25,635,395);
      setcolor(15);
      line(200,25,200,399);
      line(202,25,202,399);
     }break;
  }
  break;
       case 70:
  break;

}//end switch.

}//end fun
//----------------------------
void d()
{ union REGS in,out;
 out.h.ah=0x2a;
   intdos(&out,&out);
   int a,b,c;
   a=out.x.cx;
   b=out.h.dh;
   c=out.h.dl;
   cout<

   }
   //-------------------
void t()
  {

     union REGS in;
     in.h.ah=0x2c;
     intdos(&in,&in);
     int a,b,c,d;
     a=in.h.ch;
     b=in.h.cl;
     c=in.h.dh;
     d=in.h.dl;
     cout<    
  }

+ نوشته شده در  جمعه ششم دی ۱۳۸۷ساعت 20:11  توسط ابراری |