SpareNet Servers Advertising & Link Exchange

اطلاعیه

بستن
هیچ اطلاعیه ای هنوز ایجاد نشده است .

سورس کد های ++C

بستن
X
 
  • فیلتر
  • زمان
  • نمایش
پاک کردن همه
نوشته‌های جدید

  • سورس کد های ++C

    در این تاپیک سورس کد های ++C قرار میگیرد ، لطفا اسپم ندهید .

    سورس کد 8 وزیر

    [align=left]
    کد:
    #include <iostream>
    using namespace std;
    int chess[8][8];
    bool put(int move);
    bool check(int,int);
    int main()
    {
        int i,j;
        printf("The Chess Befor Inserting Minister In It:\n");
        for(i=0;i<8;++i)
        {
            for(j=0;j<8;j++)
                printf("%6d ",chess[i][j]);
            printf("\n");
        }
    
        put(0);
        printf("The Chess After Inserting 8 Minister In It:\n");
        for(i=0;i<8;++i)
        {
            for(j=0;j<8;j++)
                printf("%6d ",chess[i][j]);
            printf("\n\n");
        }
        return 0;
    }
    bool put(int move)
    {
        if(move>=8)
            return true;
        int i;
        for(i=0;i<8;i++)
            if(check(move,i))
            {
                chess[move][i]=1;
                if( put(move+1))
                    return true;
                else
                    chess[move][i]=0;
            }
            return false;
    }
    bool check(int row,int col)
    {
        int i,j;
        for(i=0;i<8;i++)
            if(chess[i][col])
                return false;
        for(i=row+1,j=col+1;i<8&&j<8;++i,++j)
            if(chess[i][j])
                return false;
        for(i=row-1,j=col-1;i>=0&&j>=0;--i,--j)
            if(chess[i][j])
                return false;
        for(i=row-1,j=col+1;i>=0&&col<8;i--,++j)
            if(chess[i][j])
                return false;
        for(i=row+1,j=col-1;i<8&&col>=0;++i,--j)
            if(chess[i][j])
                return false;
        return true;
    }
    [/align]

    سورس کد برج های هانوی

    [align=left]
    کد:
    #include <iostream.h>
    #include <conio.h>
    void Tower(int, char, char, char);
    void main()
    {
        clrscr();
        int num;
       cout << " Hanoy Towers : " << endl
            << " Enter Size of Tower: ";
    
       cin >> num ;
        Tower(num,'A','C','B');
    
       getch();
    
    }
    void Tower(int n, char A, char C, char B)
    {
        if(n>1) Tower(n-1,A,B,C);
          cout << A << " moved to " << C << endl;
       if(n>1) Tower(n-1,B,C,A);
    }
    [/align]
    [align=center][/align]

  • #2
    RE: سورس کد های ++C

    سورس کد بدست آوردن بزرگترین مقسوم علیه

    [align=left]
    کد:
    #include <conio.h>
    #include <iostream.h>
    int gcd(int,int);
    int main()
    {
     int x,y;
     cout<<"enter amount for x and y:";
     cin>>x>>y;
     int k=gcd(x,y);
     cout<<k;
     getch();
     return 0;
    }
    int gcd(int x,int y)
    {
     if(y==0)
      return x;
     else
      return gcd(y,x&y);
    }
    [/align]


    سورس کد تقویم به زبان سی

    [align=left]
    کد:
    #include <stdio.h>
    #include <stdlib.h>       
    #define TRUE 1
    #define FALSE 0
    int get_day_code (int year);
    int get_leap_year (int year);
    void print_calendar (FILE *fout, int year, int day_code, int leap_year);
    int get_year (void);
    main()
    {
       
       int year, day_code, leap_year; 
       
       FILE *fout;
       
       fout = fopen ("calendar.txt", "w");
       
       year = get_year();                           
       
       day_code = get_day_code (year);
       
       leap_year = get_leap_year (year);
       
       print_calendar(fout, year, day_code, leap_year);
       
       printf("Open up \'calendar.txt\' to see your calendar...\n");
       
       system("pause");
         
    }
         
    int get_year (void)
    {
    int year;
    printf ("Enter a year: ");
    scanf ("%d", &year);
    return year;
    }             
    int get_day_code (int year)
    {
    int day_code;
    int x1, x2, x3;
        x1 = (year - 1.)/ 4.0;
        x2 = (year - 1.)/ 100.;
        x3 = (year - 1.)/ 400.;
    day_code = (year + x1 - x2 + x3) %7;
    return day_code;
    }             
    int get_leap_year (int year)
    {
        
    //if((year% 4) == 0 );
    if(year% 4==0 && year%100 != 0 || year%400==0)
       return TRUE;
       else return FALSE;    
            
    }
    void print_calendar (FILE *fout, int year, int day_code, int leap_year) //function header
    {
        int  days_in_month,     /* number of days in month currently 
                                                         being printed */
             day,       /* counter for day of month */
             month;     /* month = 1 is Jan, month = 2 is Feb, etc. */
         fprintf (fout,"                   %d", year);
         for ( month = 1; month <= 12; month++ ) {
              switch ( month ) { /* print name and set days_in_month */
              case 1:
                   fprintf(fout,"\n\nJanuary" );
                   days_in_month = 31;
                   break;
              case 2:
                   fprintf(fout,"\n\nFebruary" );
                   days_in_month = leap_year ? 29 : 28;
                   break;
              case 3:
                   fprintf(fout, "\n\nMarch" );
                   days_in_month = 31;
                   break;
              case 4:
                   fprintf(fout,"\n\nApril" );
                   days_in_month = 30;
                   break;
              case 5:
                   fprintf(fout,"\n\nMay" );
                   days_in_month = 31;
                   break;
              case 6:
                   fprintf(fout,"\n\nJune" );
                   days_in_month = 30;
                   break;
              case 7:
                   fprintf(fout,"\n\nJuly" );
                   days_in_month = 31;
                   break;
              case 8:
                   fprintf(fout,"\n\nAugust" );
                   days_in_month = 31;
                   break;
              case 9:
                   fprintf(fout,"\n\nSeptember" );
                   days_in_month = 30;
                   break;
              case 10:
                   fprintf(fout,"\n\nOctober" );
                   days_in_month = 31;
                   break;
              case 11:
                   fprintf(fout,"\n\nNovember" );
                   days_in_month = 30;
                   break;
              case 12:
                   fprintf(fout,"\n\nDecember" );
                   days_in_month = 31;
                   break;
              }
              fprintf(fout,"\n\nSun  Mon  Tue  Wed  Thu  Fri  Sat\n" );
              /* advance printer to correct position for first date */
              for ( day = 1; day <= 1 + day_code * 5; day++ )
                   fprintf(fout," " );
              /* print the dates for one month */
              for ( day = 1; day <= days_in_month; day++ ) {
                   fprintf(fout,"%2d", day );
                   if ( ( day + day_code ) % 7 > 0 ) /* before Sat? */
                        /* move to next day in same week */
                        fprintf(fout,"   " );
                   else  /* skip to next line to start with Sun */
                        fprintf(fout, "\n " );
              }
              /* set day_code for next month to begin */
              day_code = ( day_code + days_in_month ) % 7;
         }
    }
    [/align]
    [align=center][/align]

    نظر


    • #3
      RE: سورس کد های ++C

      سورس کد جمع دو عدد چند جمله ای

      [align=left]
      کد:
      #include<iostream.h>
      #include<conio.h>
      #define max 20
      
      class addition;
      
      class term{
       friend addition;
       int coef;
       float exp;
      };
      
      
      class addition{
      
       static term array[50];
       static int free;
       int start;
       int finish;
      
       public:
      
         addition()
           {
            start=free;
            finish=free-1;
           }
      
         void init(int a,int b)
           {
      
             array[free].coef=a;
             array[free].exp=b;
             free++;
             finish++;
           }
      
         void add(addition M);
         char compare(int v,int s);
         void newterm(int c,int e);
         void insert();
      
      };
      //************
       void addition::newterm(int c,int e)
        {
      
         if(free>=50)
           {
             cout<<"error";
             return;
           }
      
         array[free].coef=c;
         array[free].exp=e;
         free++;
      
        }
      //************
       char addition:: compare(int v,int s)
        {
      
         if(v==s)
             return('=');
         if(v<s)
             return('<');
         return('>');
      
        }
      //************
      void addition::add(addition M)
        {
      
         addition C;
         int a=start;
         int m=M.start;
         C.start=free;
         int  c;
      
         while((a<=finish)&&(m<=M.finish))
           switch(compare(array[a].exp,array[m].exp))
            {
      
             case'=':
            c=array[a].coef+array[m].coef;
            if(c)
              newterm(c,array[a].exp);
            a++;
            m++;
            break;
      
             case'<':
            newterm(array[m].coef,array[m].exp);
            m++;
            break;
      
             case'>':
            newterm(array[a].coef,array[a].exp);
            a++;
      
            }//swich
      
         for(;a<=finish;a++)
             newterm(array[a].coef,array[a].exp);
      
         for(;m<=M.finish;m++)
             newterm(array[m].coef,array[m].exp);
      
         C.finish=free-1;
      
         cout<<endl<<endl;
         cout<<"*************"<<endl<<endl;
         cout<<endl<<"F1(X)=";
      
         for(int k=start;k<=finish;k++)
            {
      
             if(array[k].exp==0)
               cout<<array[k].coef;
             else
           cout<<array[k].coef<<"X"<<array[k].exp;
      
             if(k!=finish)
           cout<<" + ";
      
            }
      
         cout<<endl<<endl<<"F2(X)=";
         for(k=M.start;k<=M.finish;k++)
            {
      
             if(array[k].exp==0)
           cout<<array[k].coef;
             else
           cout<<array[k].coef<<"X"<<array[k].exp;
      
             if(k!=M.finish)
           cout<<" + ";
            }
      
         cout<<endl<<endl<<endl<<"F(X)=";
         for( k=C.start;k<=C.finish;k++)
            {
      
             if(array[k].exp==0)
           cout<<array[k].coef;
             else
           cout<<array[k].coef<<"X"<<array[k].exp;
      
             if(k!=C.finish)
           cout<<" + ";
            }
         return;
      }
      //************
      void addition :: insert()
      {
        int c;
        int b;
      
        do
          {
           cout<<endl<<"enter a zarib:";
           cin>>c;
           cout<<endl<<"enter a darege:";
           cin>>b;
           init(c,b);
           cout<<"pleas press a key,end of '.'";
          }while(getch()!='.');
       }
      
      term addition::array[50];
      int  addition::free=0;
      
      //************
      void main()
      {
        clrscr();
      
        addition A;
        A.insert();
      
        cout<<endl<<endl;
        cout<<"************";
        cout<<endl;
      
        addition M;
        M.insert();
      
        A.add(M);
        getch();
      }
      [/align]

      سورس کد جستجوی دو دویی به زبان ++c

      [align=left]
      کد:
      #include <conio.h>
      #include <iostream.h>
      #define MAX  10
      int binsearch(int list[],int searchnum,int n)
      {
       int find=-1;
       int s=0;
       int e=n-1;
       int mid;
       while (s<=e){
         mid=(s+e)/2;
         if (list[mid]>searchnum)
           e=mid-1;
         else if (list[mid] <searchnum)
             s=mid+1;
         else if (list[mid]==searchnum) {
           find =list[mid];
           break;
         }
      }
      return find;
      }
      //*********************************
      void main()
      {
       int a[MAX];
       for (int i=0;i<MAX;i++)
          a[i]=i;
       clrscr();
       cout<<"Enter a number:";
       int k;
       cin>>k;
       int f=binsearch(a,k,MAX);
       cout<<f;
       getch();
      }
      [/align]
      [align=center][/align]

      نظر


      • #4
        RE: سورس کد های ++C

        سورس کد بازی مد لیب به زبان ++c

        [align=left]
        کد:
        #include <iostream.h>
        #include <string.h>
        #include <stdlib.h>
        struct StringData 
            {
                char string[100];
        };
         main()
            {
                cout << "\n********** Mad Libs Example **********\n";
                cout << "\nEnter 10 Variables\n";
                StringData data[10];
                for(int i = 0; i <= 9; i++)
                    {
                        cout << "\n enter variable #" << i << ":";
                        cin >> data[i].string;
                    }
                    cout << "\n********** Your Result ******************\n";
                    cout << "\n some guy was walking down the street when: " << data[0].string << " came along\n";
                    cout << "\n then this little: " << data[1].string << " started screaming " << endl;
                    cout << "\n what happend to this, point were did it go? : " << data[2].string << endl;
                    cout << "\n how many times must I tell you this: " << data[3].string << endl;
                    cout << "\n my mind speaks of this: " << data[4].string << endl;
                    cout << "\n this is a story of a boy named .." << data[5].string << endl;
                    cout << "\n low and below, there it was..." << data[6].string << endl;
                    cout << "\n and so we kept on saying this: " << data[7].string << endl;
                    cout << "\n this is a spew of nonsense: " << data[8].string << endl;
                
                    cout << "\n bye!";
                    system("pause");
            }
        [/align]

        سورس کد بازی میز maze به زبان ++c

        [align=left]
        کد:
        #include <iostream.h>
        #include <conio.h>
        #include <stdio.h>
        #include <stdlib.h>
        #include <iomanip.h>
        #include <graphics.h>
        #include <dos.h>
        
        #define UP 72
        #define LEFT 75
        #define RIGHT 77
        #define DOWN 80
        #define ESC 27
        
        int move(int);
        void draw(void);
        int search(void);
        int strcheck(void);
        void setgraph(void);
        void message(char *);
        const n=13;
        const m=13;
        char x[m][n]={{"#############"},
                {"#####..######"},
                {"....##.#....#"},
                {"###.##.#.##.#"},
                {"###.#..#.##.#"},
                {"#...#.##.##.#"},
                {"#.###....##.#"},
                {"#.#.#.##..#.#"},
                {"#.#.#.###.#.#"},
                {"#.....###.#.#"},
                {"###.#####.#.#"},
                {"#.........#.."},
                {"#############"}};
        
        int gapi[10];
        int gapj[10];
        int si,sj;
        
        void main()
        {
           setgraph();
           draw();
           int i=search();
           if (i<=1)
           {
              message("Sorry , Maze couldn't find any way ... ");
              exit(0);
           }
           else
           {
              char *temp="There is    ways ,Press any key to try...";
              temp[9]=i+0x30;
              message(temp);
           }
        
           si=gapi[0];
           sj=gapj[0];
           x[si][sj]='M';
           draw();
           int key;
           do{
            key=getch();
            if(move(key))
                draw();
        
           }while (!strcheck() && key!=ESC);
        
          if (strcheck()==1)
            message("Congratulate, Maze find the way ... ");
           else
            message("Sorry, Maze couldn't find any way ... ");
        
           closegraph();
        }
        int search(void)
        {
            int k=0;
            int i,j;
            for (i=0;i<m;i++)
                if (x[i][0]=='.')
                    {gapi[k]=i; gapj[k++]=0;}
            for (i=0;i<m;i++)
                if (x[i][n-1]=='.')
                    {gapi[k]=i;gapj[k++]=n-1;}
            for (j=0;j<n;j++)
                if (x[0][j]=='.')
                    {gapi[k]=0;gapj[k++]=j;}
            for (j=0;j<n;j++)
                if (x[m-1][j]=='.')
                    {gapi[k]=m-1;gapj[k++]=j;}
        
            return(k);
        }
        
        int strcheck(void)
        {
           int k=0;
           if ((si==0 || si==m-1 || sj==0 || sj==n-1) && (si!=gapi[0] && sj!=gapj[0]))
            k=1;
           return(k);
        }
        
        void draw(void)
        {
           int mx=getmaxx()/n;
           int my=getmaxy()/m;
           for (int p=0;p<m;p++)
           {
             for (int q=0;q<n;q++)
             {
                switch (x[p][q]){
                case '.': setfillstyle(11,DARKGRAY);break;
                case '#': setfillstyle(1,BLUE);break;
                case 'M': setfillstyle(1,YELLOW);break;
                }
                bar(q*mx,p*my,q*mx+mx,p*my+my);
             }
           }
        }
        
        void setgraph(void)
        {
           int gd=DETECT, gm;
           initgraph (&gd,&gm,"..\\bgi");
        }
        
        void message(char *str)
        {
          setfillstyle(1,GREEN);
          bar(130,200,550,250);
          setcolor(WHITE);
          rectangle(130,200,550,250);
          setcolor(BLACK);
          settextstyle(3,0,1);
          outtextxy(140,210,str);
          delay(1500);
          getch();
        }
        
        int move(int dir)
        {
            int k=0;
            switch (dir)
            {
                case LEFT: if(x[si][sj-1]!='#'){x[si][sj]='.'; sj--; x[si][sj]='M'; } k=1; break;
                case RIGHT: if(x[si][sj+1]!='#'){x[si][sj]='.'; sj++; x[si][sj]='M'; } k=1; break;
                case UP: if(x[si-1][sj]!='#'){x[si][sj]='.'; si--; x[si][sj]='M'; } k=1; break;
                case DOWN: if(x[si+1][sj]!='#'){x[si][sj]='.'; si++; x[si][sj]='M'; } k=1; break;
            }
            return k;
        }
        [/align]
        [align=center][/align]

        نظر


        • #5
          RE: سورس کد های ++C

          سورس کد بازی RPG به زبان ++c

          [align=left]
          کد:
          #include <iostream>
          #include <cstdlib>
          #include <ctime>
          
          using namespace std;
          
          int main()
          {
            int choice;
            int mhp, hp, i, init, atk, def, matk, mdef, hurt, mhurt, agi, magi;
            atk = 10;
            def = 15;
            agi = 5;
            matk = 10;
            mdef = 15;
            magi = 5;
            
            srand((unsigned)time(0));
            init = rand()%2+1;
            mhp = rand()%50 + 60;
            hp = rand()%20 + 80;
            if (init == 1) {
            cout<<"You start.\n";
            while (hp > 0 || mhp > 0) {
              cout<<"What do you want to do?\n1 - Fierce Attack\n2 - Lithe Attack\n3 - Defensive moves\n";
               do{cin>>choice;}while(choice>3 || choice<1);
              switch (choice) {
                case 1:
                  atk = rand()%20+10;
              def = rand()%10+10;
              agi = rand()%5;
              break;
                case 2:
                  atk = rand()%5+10;
              def = rand()%10+10;
              agi = rand()%15;
                  break;
                case 3:
                  atk = rand()%10+10;
              def = rand()%20+10;
              agi = rand()%5;
              break;
              }
              choice = rand()%3;
              switch (choice) {
                case 1:
                  matk = rand()%20+10;
              mdef = rand()%10+10;
              magi = rand()%5;
              break;
                case 2:
                  matk = rand()%5+10;
              mdef = rand()%10+10;
              magi = rand()%15;
                  break;
                case 3:
                  matk = rand()%10+10;
              mdef = rand()%20+10;
              magi = rand()%5;
              break;
              }
          
          //Här dör folk o sånt
              mhurt = (atk - magi) - (mdef/atk);
              if (mhurt < 0) {
                mhurt = 0;
              }
              mhp = mhp - mhurt;
              cout<<"You did "<<mhurt<<" damage to the monster!\n";
              cin.get();
          //Specielt här
              if (mhp < 1) {
                cout<<"You killed the beast!! You won with "<<hp<<" hp left.\n";
                cin.get();
                return 0;
                }
              cout<<"The monster now have "<<mhp<<" hp left.\n";
              hurt = (matk - agi) - (def/matk);
              if (hurt < 0) {
                hurt = 0;
              }
              hp = hp - hurt;
              cout<<"The monster hit you for "<<hurt<<" damage.\n";
          //Och här.
              if (hp < 1) {
                cout<<"You died. The beast still has "<<mhp<<" hp left.\n";
                cin.get();
                return 0;
                }
          cout<<"You now have "<<hp<<" hp left.\n\n";
               }
               }
          
          //Om monstret startar.
            else {
            cout<<"Monster start.\n";
              while (hp > 0 || mhp > 0) {
              choice = rand()%3;
              switch (choice) {
                case 1:
                  matk = rand()%20+10;
              mdef = rand()%10+10;
              magi = rand()%5;
              break;
                case 2:
                  matk = rand()%5+10;
              mdef = rand()%10+10;
              magi = rand()%15;
                  break;
                case 3:
                  matk = rand()%10+10;
              mdef = rand()%20+10;
              magi = rand()%5;
              break;
              }
          //Monstret börjar!! han slår till direkt.
              hurt = (matk - agi) - (def/matk);
              if (hurt < 0) {
                hurt = 0;
              }
              hp = hp - hurt;
              cout<<"The monster hit you for "<<hurt<<" damage.\n";
          //Oooooh, gotta hurt!
              if (hp < 1) {
                cout<<"You died. The beast still has "<<mhp<<" hp left.\n";
                cin.get();
                return 0;
                }
           cout<<"You now have "<<hp<<" hp left.\n\n";
              cout<<"What do you want to do?\n1 - Fierce Attack\n2 - Lithe Attack\n3 - Defensive moves\n";
               do{cin>>choice;}while(choice>3 || choice<1);
              switch (choice) {
                case 1:
                  atk = rand()%20+10;
              def = rand()%10+10;
              agi = rand()%5;
              break;
                case 2:
                  atk = rand()%5+10;
              def = rand()%10+10;
              agi = rand()%15;
                  break;
                case 3:
                  atk = rand()%10+10;
              def = rand()%20+10;
              agi = rand()%5;
              break;
                  }
          
          
          //Här kan han dö.
              mhurt = (atk - magi) - (mdef/atk);
              if (mhurt < 0) {
                mhurt = 0;
              }
              mhp = mhp - mhurt;
              cout<<"You did "<<mhurt<<" damage to the monster!\n";
              cin.get();
          //Eller typ här:
              if (mhp < 1) {
                cout<<"You killed the beast!! You won with "<<hp<<" hp left.\n";
                cin.get();
                return 0;
                }
              cout<<"The monster now have "<<mhp<<" hp left.\n";
            } } }
          [/align]

          سورس کد بازی اس - لوت به زبان ++c

          [align=left]
          کد:
          #include <iostream.h>
          #include <stdlib.h>
          #include <time.h>
          int main()
          {
              
              int x,a, b, c, token=4;
              srand(time(0));
              
              cout<<"\t********************************************************\n"
                  <<"\t*              Welcome to slot machine.                *\n"
                  <<"\t*  Would you like to play? (1 to play, 2 not to play)  *\n"
                  <<"\t********************************************************\n\n";
              cin>>x;
              while(token!=0)
              {cout<<"You have "<<token<< " tokens\n\n"
                  <<"Pull? (1 to pull, 2 not to pull)\n\n";
              cin>>x;
              
              
              
              
              if(x==1)
          {    
              
               a = 1+rand() %10;
               b = 1+rand() %10;
               c = 1+rand() %10;
              
              
              cout<<"\t\t"<<a<<"          "<<b<<"          "<<c<<"\n\n";
              
          }
                  else
                  cout<<"OK\n";
                  {        
                          
                  if(a==b==c)
                  {
                      
                      token+=4;
                      cout<<"You win\n\n";
                  }        
                  if(a==b || b==c || a==c)
                  {
                      token+=1;
                  
                  cout<<"You got two out of three\n\n";
                  
                  
                  }
                  else
                  {
                      token-=1;
                      
                  
                  cout<<"You loose\n\n";
                  }
                  
                  }
              }
                  
                  
                          
                      return 0;
          }
          [/align]
          [align=center][/align]

          نظر


          • #6
            RE: سورس کد های ++C

            سورس کد برنامه صف بندی با آرایه :

            [align=left]
            کد:
            #include <stdio.h>
            #include <iostream.h>
            int Q[10];
            int front,rear;
            void ADD()
            {   int x;
               if (front==(rear+1) % 10)
                 {
                   printf("*****QUEUE IS FULL****\n");
                   return;
                 }
               printf("     Enter A Number: ");
               scanf("%d",&x);
               Q[rear]=x;
               rear=(rear+1) %10;
            }
            //====================================
            void Del()
            {
              if(rear==front)
               {
                 printf("  ++++Queue Is Empty!!!+++\n");
                 return;
               }
              printf("     %d     ",Q[front]);
              front=(front+1) % 10;
            }
            
            void main()
            {
             char c;
             front=0; rear=0;
             do{
                 printf("Enter A for ADD\n");
                 printf("Enter D for Delete\n");
                 printf("Enter Q for Exit\n");
                 cin>>c;
                 if (c=='a') ADD();
                 if (c=='d')Del();
             }while (c!='q');
            
            }
            [/align]

            سورس کد برنامه ساعت :

            [align=left]
            کد:
            #include <iostream.h>
            #include <conio.h>
            #include <dos.h>
            #include <math.h>
            #include <graphics.h>
            void clock_(int x,int y,int r,int c,int b);
            void setgraph (void);
            void main()
            {
                clrscr();
                setgraph();
                while(!kbhit())
                {
                    clock_(getmaxx()/2,getmaxy()/2,100,BLUE,WHITE);
            
                }
            }
            void setgraph (void)
            {
               int gd=DETECT, gm;
               initgraph (&gd,&gm,"..\\bgi");
            }
            void clock_(int x,int y,int r,int c,int b)
            {
               struct  dostime_t t;
               double p=3.1415;
               setcolor(b);
               setlinestyle(0,0,3);
               circle(x,y,r);
               settextstyle(2,0,4);
               outtextxy(x-5,y-r+1,"12");
               outtextxy(x-3,y+r-13,"6");
               outtextxy(x+r-10,y-5,"3");
               outtextxy(x-r+5,y-5,"9");
               _dos_gettime(&t);
               setcolor(c);
               setlinestyle(1,0,1);
               setfillstyle(1,c);
               pieslice(x,y,0,360,r-11);
               setcolor(b-2);
               line(x,y,x+(r-25)*(cos((t.hour*6-90)*p/180)),y+(r-25)*sin((t.hour*6-90)*p/180));
               line(x,y,x+(r-16)*(cos((t.minute*6-90)*p/180)),y+(r-16)*sin((t.minute*6-90)*p/180));
               setcolor(b);
               setlinestyle(0,0,1);
               line(x-(10)*(cos((t.second*6-90)*p/180)),y-(10)*sin((t.second*6-90)*p/180),x+(r-12)*(cos((t.second*6-90)*p/180)),y+(r-12)*sin((t.second*6-90)*p/180));
            
               char s[10];
               setcolor(11);
               circle(x,y,2);
            }
            [/align]
            [align=center][/align]

            نظر


            • #7
              RE: سورس کد های ++C

              سورس کد برنامه تبدیل مبنا :

              [align=left]
              کد:
              #include <stdio.h>
              #include <iostream.h>
              #include <conio.h>
              void main(){
                              int num_org,num,i,j,k,b,r,m;
                              clrscr();
                              cout<<"Please enter number in decimal mode:";
                              cin>> num_org;
                              cout<<"Please inter base number ( 2=>,<=16 ):";
                              cin >> m;
                              if (m<2 || m>16) return;
                              num=num_org;
                              i=0;
                              for (;num>=m;){
                                              num/=m;
                                              i++;
                              }
                              cout<<num;
                              for(j=i;j>0;j--){
                                              num=num_org;
                                              for(k=0;k<j;k++){
                                                              b=num%m;
                                                              num/=m;
                                              }
                                              cout<<b;
                              }
              getch();
              return 0;
              }
              [/align]

              سورس کد بازی تانک به زبان سی (بصورت گرافیکی) پیشنهاد میکنم حتما دانلود کنید :

              [align=left]
              کد:
              http://uploaderx.persiangig.com/C/tank3b5.zip
              [/align]
              [align=center][/align]

              نظر


              • #8
                RE: سورس کد های ++C

                سورس کد برنامه طراحی منوی گرافیکی :

                [align=left]
                کد:
                #include <iostream.h>
                #include <conio.h>
                #include <dos.h>
                #include <graphics.h>
                
                //Menu Global Item
                #define pixTOrc(x) (8*(x-1))  //convert pixel into row and col format
                #define INC 5  //Increment Distance Between Menu Items
                #define ROW 15 //Row Value for Menu Item
                #define COL 8 //Column Value for Menu Item
                #define MAXITEM 5 //Total menu items
                
                // To display the Inventory Main menu options
                typedef char option[15];
                option mainMenu[]= {
                  "NEW",
                  "OPEN",
                  "SAVE",
                  "ABOUT ME",
                  "CLOSE"
                };
                
                
                // Function to displays all the menu prompt messages from the pointer array of option a[]
                void normalvideo(int x,int y,char *str)
                {
                    x=pixTOrc(x);
                    y=pixTOrc(y);
                    outtextxy(x,y,str);
                }
                
                // Function to move the cursor on the menu prompt with a reverse video color
                void reversevideo(int x,int y,char *str)
                {
                x=pixTOrc(x);
                y=pixTOrc(y);
                setcolor(YELLOW);  //Selected Item
                sound(400);
                delay(100);
                nosound();
                outtextxy(x,y,str);
                setcolor(WHITE); //Unselected Item
                sound(500);
                delay(100);
                nosound();
                }
                
                
                //Keep Track of which arrow key is pressed
                char menu()
                {
                settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
                setcolor(WHITE);  //Initial Menu Item Color
                int i,done;
                for(i = 1; i < MAXITEM; i++)
                  normalvideo(COL, (i*INC)+ROW, mainMenu[i]);
                
                reversevideo(COL,ROW, mainMenu[0]);
                i = done = 0;
                do
                {
                /**Status Bar Logic**/
                //Message will be displayed as status bar guide-line
                setfillstyle(SOLID_FILL,BLUE);
                settextstyle(SMALL_FONT,HORIZ_DIR,5);
                bar(pixTOrc(2),pixTOrc(52.5),pixTOrc(75),pixTOrc(55));
                setcolor(LIGHTCYAN);
                switch(i){
                case 0 : outtextxy(pixTOrc(5),pixTOrc(52.75),"New --> Create New file");
                break;
                case 1 : outtextxy(pixTOrc(5),pixTOrc(52.75),"Open --> Open Existing file");
                break;
                case 2 : outtextxy(pixTOrc(5),pixTOrc(52.75),"Save --> Save file");
                break;
                case 3 : outtextxy(pixTOrc(5),pixTOrc(52.75),"About Me --> Programmer : Vivek Patel");
                break;
                case 4 : outtextxy(pixTOrc(5),pixTOrc(52.75),"Close the Program --> BYE C U");
                break;
                }
                /**status Bar ends**/
                
                //Restore Orignal Color and Font Setting
                setcolor(WHITE);
                settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
                
                ssss int key = getch();
                switch (key)
                {
                
                case 00:
                key = getch();
                switch (key)
                {
                case 72:
                normalvideo(COL, (i*INC)+ROW, mainMenu[i]);
                i--;
                if (i == -1)
                i = MAXITEM-1;
                reversevideo(COL,(i*INC)+ROW,mainMenu[i]);
                break;
                case 80:
                normalvideo(COL, (i*INC)+ROW, mainMenu[i]);
                i++;
                if (i == MAXITEM)
                i = 0;
                reversevideo(COL, (i*INC)+ROW, mainMenu[i]);
                break;
                }
                break;
                case 13:
                done = 1;
                }
                }
                while (!done);
                return(i+49);
                }
                
                
                //Advertise Screen will displayed to utilize empty screen area
                //It can be utilize for some effective...work
                void advertise(){
                setcolor(BLUE);
                outtextxy(pixTOrc(30),pixTOrc(20),"URL  : cpp.blogfa.com");
                outtextxy(pixTOrc(30),pixTOrc(26),"Mail : [email protected]");
                setcolor(YELLOW);
                }
                
                
                /* The function is used to display the main menu*/
                //Actual code for all the menu utility resides in this
                //Function...
                void control_menu()
                {
                     char choice;
                do
                {
                choice = menu();
                switch (choice)
                {
                   case '1':    //New
                setcolor(BLUE);
                outtextxy(pixTOrc(40),pixTOrc(15),"New");
                advertise();
                getch();
                setfillstyle(SOLID_FILL,LIGHTGRAY);
                bar(pixTOrc(28),pixTOrc(14),pixTOrc(75),pixTOrc(50));
                advertise();
                break;
                
                   case '2':    //Open
                setcolor(BLUE);
                outtextxy(pixTOrc(40),pixTOrc(15),"Open");
                advertise();
                getch();
                setfillstyle(SOLID_FILL,LIGHTGRAY);
                bar(pixTOrc(28),pixTOrc(14),pixTOrc(75),pixTOrc(50));
                advertise();
                break;
                
                   case '3':    //Save
                setcolor(BLUE);
                outtextxy(pixTOrc(40),pixTOrc(15),"Save");
                advertise();
                getch();
                setfillstyle(SOLID_FILL,LIGHTGRAY);
                bar(pixTOrc(28),pixTOrc(14),pixTOrc(75),pixTOrc(50));
                advertise();
                break;
                
                   case '4':    //Modify the status of item in inventory
                setcolor(BLUE);
                outtextxy(pixTOrc(40),pixTOrc(15),"About Me");
                advertise();
                getch();
                setfillstyle(SOLID_FILL,LIGHTGRAY);
                bar(pixTOrc(28),pixTOrc(14),pixTOrc(75),pixTOrc(50));
                advertise();
                break;
                
                   case '5':    //Close the program
                setcolor(BLUE);
                outtextxy(pixTOrc(40),pixTOrc(15),"CLOSE");
                advertise();
                delay(1000);
                setfillstyle(SOLID_FILL,LIGHTGRAY);
                bar(pixTOrc(28),pixTOrc(14),pixTOrc(75),pixTOrc(50));
                advertise();
                goto out;
                   }
                  } while (choice != MAXITEM);
                out:
                }
                
                
                
                void main()
                {
                int i,j;
                
                int gd=DETECT,gm=0;
                initgraph(&gd,&gm,"c:\\tc\\bgi\\");
                
                ///code as space holder\\\\\
                setfillstyle(SOLID_FILL,LIGHTGRAY);
                bar(0,0,640,480);
                
                setcolor(DARKGRAY);
                rectangle(0,0,639,480);
                rectangle(1,1,638,479);
                setcolor(BLACK);
                rectangle(2,1,637,478);
                rectangle(3,1,636,477);
                
                settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
                setcolor(BLUE);
                outtextxy(pixTOrc(8),pixTOrc(2),"  MENU  -->>  (Simple Style) ");
                
                setfillstyle(HATCH_FILL,DARKGRAY);
                for(i=15,j=70;i<40||j>40;i++,j--){
                bar(pixTOrc(8),pixTOrc(7),pixTOrc(i),pixTOrc(7.5));
                delay(10);
                bar(pixTOrc(j),pixTOrc(7),pixTOrc(70),pixTOrc(7.5));
                delay(20);
                }
                
                bar(pixTOrc(7),pixTOrc(14),pixTOrc(25),pixTOrc(50));
                
                ///code as space holder\\\\\
                
                //Calling Menu
                control_menu();
                
                closegraph();
                }
                [/align]

                سورس کد برنامه توان بازگشتی به زبان ++c

                [align=left]
                کد:
                #include <iostream.h>
                #include <conio.h>
                int power(int,int);
                int main()
                {
                 int exp,base;
                 cout<<"enter base,exp:";
                 cin>>base>>exp;
                int h=power(base,exp);
                 cout<<"it equals by:"<<h;
                 getch();
                 return 0;
                }
                int power(int base,int exp)
                {
                 if(exp==1)
                  return base;
                 else
                 
                  return base*power(base,exp-1);
                }
                [/align]
                [align=center][/align]

                نظر


                • #9
                  RE: سورس کد های ++C

                  سورس کد برنامه notepad به زبان سی :

                  [align=left]
                  کد:
                  #include<dos.h>
                  #include<process.h>
                  #include<string.h>   // for various functions of strings like gets or puts
                  #include<fstream.h>   // for files
                  #include<stdio.h>
                  #include<iostream.h>
                  #include<conio.h>
                  void starting();
                  void typing();
                  void openfile(char *);
                  void newfile(char *);
                  void print(char i[],int x,int y);
                  
                  char ch ;
                  char s[20];
                  char xs[20];
                  char ys[20];
                  
                  void main()
                  {
                  	clrscr();
                  	textmode(BW40);
                  	print(" MY NOTEPAD ",3,14);
                  	print(" Presented",6,14);
                  	print(" By ",7,17);
                  	print(" Zahid Ashfaq",8,13);
                  
                  
                        textmode(BW80);
                  
                  starting();
                  
                  
                    typing();
                     getch();
                     }
                  
                  
                  
                   void starting()
                   {   textcolor(1);
                       textbackground(WHITE);
                  
                  
                      clrscr();
                      for(int i=0 ;i<45;i++)
                      {if(i==0||i==44)
                         cout<<"||";
                         else if(i==4)
                         cout<<" ctrl+O(Open file)";
                         else if(i==24)
                         cout<<" ctrl+n(New file)";
                         else
                         cout<<"=";}
                  		gotoxy(80,24);  cout<<endl;
                  	 for( i=0 ;i<37;i++)
                      {if(i==0||i==47)
                         cout<<"||";
                         else if(i==4)
                         cout<<" ctrl+s(save file)";
                         else if(i==16)
                         cout<<" ctrl+k(Help)";
                         else if(i==26)
                         cout<<"ctrl+q(Quit)";
                         else
                         cout<<"=";}
                  }
                  
                  
                  void typing()
                  {  int i=0;
                      char *p=new char[2000];
                   step1 :  int row=2 ,col=1;
                   while(ch!=19)
                  {
                  gotoxy(col,row);
                  
                    step2:  if(col==79)
                       {col=1;row++;}
                      else if (row==24)
                        goto step1;
                  	int a;
                  	ch=getch();
                  	if(ch == 0)
                  	ch = getch();
                  
                  	  a=ch;  // To convert character to its ascii code
                  
                  	  switch(a)
                  {
                  case 13 : row=row++;col=1;      // case for press enter for next line
                  	    gotoxy(col,row);
                  	    ch='\n';
                  	    break;
                  
                  case 8 :
                  	      if(col==1)           // case for backspace
                  	     {row--;col=78;}
                  	   else
                  	    {col--;
                  	    cout<<"  ";
                  	     i--;
                  	    }
                  	    continue;
                  
                  case 9 :    col=col+8;           // case for tab function
                  	     if(col>79)
                  	    {row++;col=col-79;
                  	    }
                  	     continue;
                  
                  case 72 : row--;              //upper arrow key
                  	   continue;
                  
                  case 77 : col++; continue;     //right arrow key
                  
                  case 75 : col--; continue;    //left arrow key
                  
                  case 80 :                     //down arrow key
                  	   row++;
                  	   continue;
                  
                  case 14 :   clrscr();       //to creat new file ctrl+n
                  	    cout<<"Enter File`s Path ";
                  	    gets(s);
                  	    newfile(s);
                  	    starting();
                  	    break;
                  
                  case 15 :     clrscr();   //to open existing file  ctrl+o
                  	      cout<<"Enter file`s path to be open :" ;
                  	      gets(xs);
                  	      starting();
                  	      openfile(xs);
                  	      continue;
                  
                  
                  
                  
                  case 11 :     clrscr();
                  	      gotoxy(20,3);
                  	      cout<<"~`~`~`~`~  HELP PORTION  ~`~`~`~`~";
                  	      gotoxy(20,4);
                  	      cout<<"Following Are the Keys Used in My-Note PAD : ";
                  		 int za=10;
                  	      for(int i=0;i<46 ;i++ )
                  	      {
                  	       gotoxy(za,5);
                  		cout<<"=";za++;}
                  		 za=6;
                  	       for(i=0;i<15;i++)
                  	       {gotoxy(10,za);
                  		 cout<<"|"<<endl;
                  
                  		 za++;}
                  		     za=10;
                  	       for( i=0;i<46 ;i++ )
                  	      {
                  	       gotoxy(za,21);
                  		cout<<"=";
                  		za++;}
                  		 za=6;
                  	      for(i=0;i<15;i++)
                  	       {gotoxy(56,za);
                  		 cout<<"|"<<endl;
                  
                  		 za++;}
                  
                  	     gotoxy(13,6);
                  	     cout<<" 1-To Open File Press  ( ctrl + o ) ";
                  	     gotoxy(13,8);
                  	     cout<<" 2-To create New File Press(ctrl+n) " ;
                  	     gotoxy(13,10);
                  	     cout<<" 3-MOve Arrow keys (up,down,right,left)" ;
                  	     gotoxy(13,12);
                  	     cout<<" 4-Back Space ";
                  	     gotoxy(13,14);
                  	     cout<<" 5-Save File(ctrl+s)";
                  	     gotoxy(13,16);
                  	     cout<<" 6-Enter For new line ";
                  	     gotoxy(13,18);
                  	     cout<<" 7-Enter ctrl+q(Quit)";
                  
                  	     gotoxy(13,20);
                  	     cout<<"Press any key to Go back " ;
                  
                  		  getch();
                  	      clrscr();
                  	     starting();
                  
                  		 continue;
                  
                  
                  case 17 :  clrscr();
                  	   gotoxy(24,6);
                  	   cout<<"Thank You For using PIcs-soft Word ";
                  	   cout<<endl;
                  	   gotoxy(24,8);
                  	   cout<<"Have A NIce Time ";
                  	   getch();
                  	   exit(0);
                  
                  
                  
                  
                  
                  
                    }
                  
                      cout<<ch;
                  	  p[i]=ch;
                  	   col++; i++;
                  
                  	 p[i]='\0';
                         }
                         clrscr();
                         cout<<"enter path where you want to save the file ";
                         gets(ys);  int j=0;
                         ofstream f1(ys,ios::out);
                  			while(p[j]!='\0')
                  	   {f1.write((char*)&p[j],sizeof(p[j]));
                  	    j++;}
                  	   f1.close();
                  	  delete [] p;
                  	 exit(0);
                  
                  
                  
                  }
                  
                  
                  void newfile(char *s)
                  {
                     ofstream file(s,ios::out);
                     file.close();
                  }
                  
                  void openfile(char *xs)
                  { char ch;  int col=3,row=2;
                  gotoxy(col,row);
                    ifstream file(xs,ios::in);
                    while( file.read((char*)&ch,sizeof(ch)))
                                      cout<<ch;
                  
                  		   file.close();
                  }
                  
                  
                  void print(char i[],int x,int y)
                  	{
                  	char far* ptr=(char far*) 0xB8000000+(160*x)+(2*y) ;
                  	for(int a=0; i[a]!='\0'; a++)
                  		{
                  		*ptr=i[a];
                  		*(ptr+1)=16;
                  		ptr=ptr+2;
                  		delay(250);
                  		}
                  	ptr=ptr+2;
                  	}
                  [/align]

                  سورس کد برنامه ساختار رشته ای دانشجو
                  برنامه ای عالی و کاربردی برای ثبت ، ویرایش ، جستجو در ساختار رشته ای :

                  [align=left]
                  کد:
                  #include <iostream.h>
                  #include <conio.h>
                  #include <io.h>
                  #include <string.h>
                  #include <stdio.h>
                  #include <process.h>
                  typedef struct daneshjo
                  {
                  char name[30];
                  char family[30];
                  char father[30];
                  char date[30];
                  int code;
                  char nimsal[30];
                  int vorod;
                  };
                  typedef struct vahed1
                  {
                  int code;
                  int term;
                  int vahed;
                  int vahedp;
                  float moadel;
                  };
                  void reportvahed();
                  void del();
                  void vahed();
                  void search();
                  void show();
                  void add();
                  void main()
                  {
                  textbackground(1);
                  textcolor(6);
                  clrscr();
                  int i;
                  while (100){
                  clrscr();
                  
                  cout<<"\n1-Add Daneshjo In Bank";
                  cout<<"\n2-Delete Daneshjo In bank";
                  cout<<"\n3-Search Informsation In Bank";
                  cout<<"\n4-Add Tedad Vahed";
                  cout<<"\n5-Report Of Vahed";
                  cout<<"\n6-Exit";
                  cout<<"\nInsert Parametr: ";
                  cin>>i;
                  switch (i)
                  {
                  case 1:
                  add();
                  break;
                  case 2:
                  del();
                  break;
                  case 3:
                  search();
                  //show();
                  break;
                  case 4:
                  vahed();
                  break;
                  case 5:
                  reportvahed();
                  break;
                  case 6:
                  exit(0);
                  break;
                  }
                  }
                  }//end main
                  void search()
                  {
                  clrscr();
                  FILE *f;
                  int x,y,i;
                  x=y=0;
                  daneshjo d;
                  cout<<"Insert Code Of Daneshjo :";
                  cin>>i;
                  f=fopen("daneshjo.txt","rb");
                  if (f!=NULL)
                  {
                  rewind(f);
                  while (!feof(f))
                  {
                  fread(&d,sizeof(struct daneshjo),1,f);
                  if (d.code==i)
                  {
                  cout<<"-----------------------------"<<endl;
                  cout<<"Name :"<<d.name<<endl;
                  cout<<"Family :"<<d.family<<endl;
                  cout<<"Father Name :"<<d.father<<endl;
                  cout<<"Date Of Tavalod :"<<d.date<<endl;
                  cout<<"Code Of Daneshjo :"<<d.code<<endl;
                  cout<<"Sale Vorodi :"<<d.vorod<<endl;
                  cout<<"Nimsale Vorodi :"<<d.nimsal<<endl;
                  cout<<"-----------------------------";
                  getch();
                  x=1;
                  break;
                  }
                  else
                  {
                  y=1;
                  }
                  }
                  }
                  if (y==1 && x==0)
                  {
                  cout<<"Your Code IS Not Valid...";
                  getch();
                  }
                  fcloseall();// end of fuction
                  }
                  void vahed()
                  {
                  clrscr();
                  FILE *f,*f1,*f2;
                  int x,i,y;
                  daneshjo d;
                  vahed1 v;
                  x=y=0;
                  cout<<"Insert Code Of Daneshjo :";
                  cin>>i;
                  f=fopen("daneshjo.txt","rb");
                  if (f!=NULL)
                  {
                  while (!feof(f))
                  {
                  fread(&d,sizeof(struct daneshjo),1,f);
                  if (d.code==i)
                  {
                  f1=fopen("vahed.txt","a+b");
                  cout<<"Insert Tead Vahed :";
                  cin>>v.vahed;
                  cout<<"Insert Tedad Vahed Pas Shode:";
                  cin>>v.vahedp;
                  cout<<"Insert Shomare Term :";
                  cin>>v.term;
                  cout<<"Moadel Term :";
                  cin>>v.moadel;
                  v.code=i;
                  fwrite(&v,sizeof(struct vahed1),1,f1);
                  x=1;
                  break;
                  }
                  else
                  {
                  y=1;
                  }//else if 2 in while 1  mojodi kamtar
                  }
                  }
                  if (y==1 && x==0)
                  {
                  cout<<"Your Code IS Not Valid...";
                  }
                  else
                  {
                  cout<<"Information Saved In Bank...";
                  }
                  getch();
                  fcloseall();
                  }
                  void del()
                  {
                  clrscr();
                  FILE *f,*f1;
                  int i;
                  daneshjo d;
                  cout<<"Insert Code Of Daneshjo :";
                  cin>>i;
                  f=fopen("daneshjo.txt","rb");
                  f1=fopen("d.txt","a+b");
                  if (f!=NULL)
                  {
                  rewind(f);
                  while (!feof(f))
                  {
                  fread(&d,sizeof(struct daneshjo),1,f);
                  if (d.code==i)
                  {
                  }
                  else
                  {
                  fwrite(&d,sizeof(struct daneshjo),1,f1);
                  }//else if 2 in while 1  mojodi kamtar
                  }
                  }
                  remove("daneshjo.txt");
                  rename("d.txt","daneshjo.txt");
                  fcloseall();// end of fuction
                  }
                  void add()
                  {
                  clrscr();
                  FILE *f;
                  int x,y;
                  daneshjo d,d1;
                  y=0;
                  x=0;
                  cout<<"Insert Name Of Daneshjo :";
                  cin>>d.name;
                  cout<<"Insert Family Of Daneshjo :";
                  cin>>d.family;
                  cout<<"Insert Father Name Of Daneshjo :";
                  cin>>d.father;
                  cout<<"Insert Date Of Tavalod :";
                  cin>>d.date;
                  cout<<"Insert Code Of Daneshjo :";
                  cin>>d.code;
                  cout<<"Insert Sale Vorodi :";
                  cin>>d.vorod;
                  cout<<"Insert Nimsale Vorodi :";
                  cin>>d.nimsal;
                  if (d.name!="")
                  {
                  f=fopen("daneshjo.txt","a+b");
                  if (f!=NULL)
                  {
                  while (!feof(f))
                  {
                  fread(&d1,sizeof(struct daneshjo),1,f);
                  if (d1.code==d.code)
                  {
                  x=1;
                  break;
                  }
                  else
                  {
                  y=1;
                  }//else if 2 in while 1  mojodi kamtar
                  }
                  }
                  else
                  {
                  fwrite(&d,sizeof(struct daneshjo),1,f);
                  }
                  }
                  if (x==0 && y==1)
                  {
                  fwrite(&d,sizeof(struct daneshjo),1,f);
                  }
                  else
                  {
                  clrscr();
                  cout<<"Code Daneshjoee Tekrari ast...";
                  getch();
                  }
                  fcloseall();// end of fuction
                  }
                  void show()
                  {
                  clrscr();
                  vahed1 t;
                  FILE *f;
                  f=fopen("vahed.txt","rb");
                  while (!feof(f))
                  {
                  fread(&t,sizeof(struct vahed1),1,f);
                  cout<<t.code<<endl;
                  cout<<t.vahed<<endl;
                  cout<<t.vahedp<<endl;
                  getch();
                  }
                  
                  
                  
                  }
                  void reportvahed()
                  {
                  clrscr();
                  vahed1 t;
                  FILE *f;
                  int x,i,y,j,c;
                  
                  x=y=c=0;
                  f=fopen("vahed.txt","rb");
                  cout<<"Please Insert Code Of Daneshjo :";
                  cin>>i;
                  while (!feof(f))
                  {
                  
                  fread(&t,sizeof(struct vahed1),1,f);
                  if (t.code==i)
                  {
                  c++;
                  clrscr();
                  cout<<"-------------------------"<<endl;
                  cout<<"Code Daneshjo :"<<t.code<<endl;
                  cout<<"Tedad Kol Vahed :"<<t.vahed<<endl;
                  cout<<"Tedad Vahedhaye Pas Shode :"<<t.vahedp<<endl;
                  cout<<"Shomare Term :"<<t.term<<endl;
                  cout<<"Moadele Term :"<<t.moadel<<endl;
                  cout<<"-------------------------"<<endl;
                  j=j+t.moadel;
                  getch();
                  x=1;
                  }
                  else
                  {
                  y=1;
                  }
                  }
                  if (y==1 && x==0)
                  {
                  cout<<"Your Code IS Not Valid...";
                  getch();
                  }
                  else
                  {
                  
                  cout<<"Moadele Kole Daneshjo :"<<j/c-1<<endl;
                  
                  getch();
                  }
                  fcloseall();
                  
                  
                  }
                  [/align]
                  [align=center][/align]

                  نظر


                  • #10
                    RE: سورس کد های ++C

                    سلام و درود
                    از آقا حسین بخاطر ایجاد این تاپیک ممنونم
                    قرار شده در چندین پست برنامه هایی که اکثر در دانشگاه ها استادید میدن رو نوشته و قرار دهم ( با آقا حسین هماهنگ شده )
                    البته این مسائل ساده هستن و لی مطمئنا برای دانشجو ها مفید هست
                    موفق باشید
                    سوال : برنامه ای بنویسید که یک مقدار صحیح و یک مقدار اعشاری را چاپ کن ؟[align=left]
                    کد:
                    #include<iostream.h>
                    #include<conio.h>
                    int main()
                    {
                       int x=52;
                       float y=11.3;
                       cout<<"X:"<<x<<"\n";
                       cout<<"Y:"<<y;
                       getch();
                       return 0;
                    }
                    [/align]
                    [hr]
                    سوال : برنامه ای بنویسید که دو مقدار صحیح و مجموعه مربعات آن ها را در صفحه چاپ کند ؟

                    کد:
                    #include<iostream.h>
                    #include<conio.h>
                    int main()
                    {
                       int x=4;
                       int y=7;
                       cout<<"x="<<x<<"\n";
                       cout<<"y="<<y<<"\n";
                       int z=x*4+y*7; //albate mitonid az in code ham estefade konid   int z=x*x+y*y;
                       cout<<"z="<<z;
                       getch();
                       return 0;
                    }
                    موفق باشید 
                    [align=center]IranHack Security Team
                    My Home
                    YAhoo : Faridmahdavi00
                    Net-Line.ir


                    Coming Soon Android[/align]

                    نظر


                    • #11
                      RE: سورس کد های ++C

                      سورس کد برنامه کرنومتر

                      کد:
                      #include<iostream>
                      #include<time.h>
                      using namespace std;
                      int main()
                      {
                       tm *t;
                       t=new tm;
                       while(1)
                       {
                       system("cls");
                       cout<<clock ()/1000%10;
                       }
                       return 0;
                      سورس کد بازی مار - Snake به زبان ++C

                      کد:
                      #include<stdio.h>
                      #include<conio.h>
                      #include<stdlib.h>
                      #include<dos.h>
                      struct dom
                      {
                      int makanx; // makan - satr
                      int makany; // makan - sotoon
                      int makanGablyx; // makan gably - satr
                      int makanGablyy; // makan gably - sotoon
                      } dom[100]; // haddeAksare tedade dom = 100
                      int jahatha[2][5]={{-1,0,1,0},{0,1,0,-1}};
                      int te_dom=5,i,mousex,mousey,jahat=1; //0=up 1=right 2=down 3=left
                      void main()
                      {
                      char c;
                      textmode(C80); // set the screen to :: (25)Rows & (80)Columes
                      
                      randomize();
                      Start:
                      jahat =1 ;
                      
                      mousex=random(20)+2; // moshakhas kardane makane toome (x) be sorate tasadofi
                      mousey=random(76)+2; // moshakhas kardane makane toome (y) be sorate tasadofi
                      for(i=0;i<te_dom;i++)
                      {
                      dom[i].makanx=20; // makan avvaliye
                      dom[i].makany=2; // makan avvaliye
                      dom[i].makanGablyx=20; // makan avvaliye
                      dom[i].makanGablyy=2; // makan avvaliye
                      }
                      textcolor(15);
                      textbackground(1);
                      clrscr();
                      
                      gotoxy(mousey,mousex);
                      printf("M"); // nomayesh dadane toome
                      while(1)
                      {
                      if(kbhit()!=0) //agar kelidi zade shode bashad yek adade geire sefr barmigardanad
                      {
                      c=getch();
                      if(c==27) return; // dokmeye <ESC> zade shod
                      else if(c==77) jahat=1; // dokmeye <right> zade shod
                      else if(c==75) jahat=3; // dokmeye <left> zade shod
                      else if(c==72) jahat=0; // dokmeye <up> zade shod
                      else if(c==80) jahat=2; // dokmeye <button> zade shod
                      }//kbhit
                      dom[0].makanGablyx=dom[0].makanx;// zakhireye makane fely x
                      dom[0].makanGablyy=dom[0].makany;// zakhireye makane fely y
                      dom[0].makanx+=jahatha[0][jahat]; // harekate yek tekke az snak - x
                      dom[0].makany+=jahatha[1][jahat]; // harekate yek tekke az snak - y
                      gotoxy(dom[0].makany,dom[0].makanx);
                      printf("");
                      
                      int tx,ty;
                      for(i=1;i<te_dom;i++)
                      {
                      dom[i].makanGablyx=dom[i].makanx; // zakhireye makane fely x
                      dom[i].makanGablyy=dom[i].makany; // zakhireye makane fely y
                      dom[i].makanx=dom[i-1].makanGablyx; // harakat dadane yek tekke az dom be makane gabliye tekke dome balayi - x
                      dom[i].makany=dom[i-1].makanGablyy; // harakat dadane yek tekke az dom be makane gabliye tekke dome balayi - x
                      gotoxy(dom[i].makany,dom[i].makanx);
                      printf("‏"); // rasm e yek tekke az dom
                      }
                      delay(100);
                      gotoxy(dom[te_dom-1].makanGablyy,dom[te_dom-1].makanGablyx);
                      printf(" "); // pak kardane makan e gabliye tekke dome akhari
                      if(dom[0].makany<=0 || dom[0].makany>80 || dom[0].makanx<=0 || dom[0].makanx>=24) // kharej az safhe
                      {
                      printf("YOU LOST");
                      getch();
                      return;
                      }
                      if(dom[0].makanx==mousex && dom[0].makany==mousey ) // snake be mouse resid.
                      {
                      gotoxy(37,12);
                      printf("YOU WIN");
                      getch();
                      te_dom++;
                      if (te_dom<100) goto Start;
                      }
                      }
                      }
                      [align=center][/align]

                      نظر


                      • #12
                        RE: سورس کد های ++C

                        سوال : برنامه ای بنویسید که یک عدد صحیح از ورودی را به عنوان شعاع دایره ای از ورود خوانده مساحت و محیط آن را محاسبه و نمایش دهد ؟[img]images/smilies/Smileys/57.gif[/img]
                        کد:
                        #include<IOSTREAM.H>  
                        #include<conio.h>
                        #define p1 3.14
                        int main()
                        {
                           int r;
                           float a,p:
                           cout<<"Lotfan Adad Sahih Ra Vared konid:";
                           cin>>r;
                           a=p1*r*r;
                           p=2*p1*r;
                           cout<<"Masahat is: "<<a<<"\n Mohit is:"<<p;
                           getch();
                           return 0;
                        }
                        اینم برا تست رو سیستم خودم


                        موفق باشید
                        [align=center]IranHack Security Team
                        My Home
                        YAhoo : Faridmahdavi00
                        Net-Line.ir


                        Coming Soon Android[/align]

                        نظر


                        • #13
                          RE: سورس کد های ++C

                          سلام و درود

                          سوال : برنامه ای بنویسید که 3 عدد را از ورودی خوانده سپس میانگین آنها را محاسبه کرده و چاپ کند ؟

                          << دانلود کد برنامه >>

                          << تصویر >>

                          با تشکر
                          [align=center]IranHack Security Team
                          My Home
                          YAhoo : Faridmahdavi00
                          Net-Line.ir


                          Coming Soon Android[/align]

                          نظر


                          • #14
                            RE: سورس کد های ++C

                            سوال : برنامه ای بنویسید که طول و عرض مستطیل را از ورودی خوانده  و محیط . مساحت آن را محاسبه کند (خروجی را در ستون 10 و سطر 30 نمایش دهد)؟

                            نکته : در این برنامه استفاده از تابع gotoxy را با هم یاد میگیریم [align=left]
                            کد:
                            #include<iostream.h>
                            #include<conio.h>
                            int main()
                            {
                               int a,b,s,p;
                               clrscr();
                               cout<<"Lotfan Adad Ra Vared Konid:";
                               cin>>a>>b;
                               s=a*b;
                               p=2*(a*b);
                               gotoxy(10,30);
                               cout<<"Masahat:"<<s<<"\n Mohit:"<<p;
                               getch();
                               return 0;
                            }
                            [/align]
                            [align=center]IranHack Security Team
                            My Home
                            YAhoo : Faridmahdavi00
                            Net-Line.ir


                            Coming Soon Android[/align]

                            نظر

                            صبر کنید ..
                            X