1. مهمان گرامی، جهت ارسال پست، دانلود و سایر امکانات ویژه کاربران عضو، ثبت نام کنید.
    بستن اطلاعیه

مجموعه برنامه های نوشته شده به زبان C و ++C

شروع موضوع توسط hector2141 ‏11/9/12 در انجمن C #C++

  1. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    [h=2]منوی حساس به جهت های بالا و پایین[/h] سلام دوستان این برنامه را قبلا گذاشته ام اما حالا ان را با استفاده از تابع gotoxy() بازنویسی کردم تا از delay ان کمتر بشه
    این یه برنامه است که با استفاده از ان می تونید یک منوی که با جهت های بالا و پایین حساس است بسازید.
    توضیحات اضافی را درخود برنامه گذاشتم......
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    [/TD]
    [TD="class: code"]/* Menu Shower V 1.1
    Compile with visual C++‎ 6
    Programmer:Milad Kakoli(Kitten)
    E-main:hellcrueldictator@yahoo.com
    Weblog:kitten
    yek code besyar sade baraye nemayesh yek menu sade ke omidvaram
    dafa'at bad betonam ziba tar va karamad taresh konam.
    in code ghabliat shenakht jahhat haye bala va paiine baraye
    moshakhas kardan gozine entekhab shode ra darad va ba zadan enter
    halghe payan yafte gozine entekhab shode moshakhas mishavad
    baraye etela'at bishtar be weblog moraje'e konid.
    */
    #include<iostream.h>
    #include<string.h>
    #include<stdio.h>
    #include<conio.h>
    #include <windows.h>
    int ch; //braye gereftan jahat
    int row=0; //moshakhas kardan satr fa'al
    #define MAX 40 // bishtarin tedad char moton
    char uptext[1][MAX]; // matne balaye menu
    bool chi=true;
    struct Student
    {
    int tedad; // tedad gozinehaye ghabel entekhab
    char moton[5][MAX]; // moton gozinehaye ghabel entekhab
    };Student s;
    /*tabe menu ke moton menu ra print mikonad*/
    int menu() {
    cout<< uptext[0]<<endl;//print matne balaye menu
    for (int i=0 ;i < s.tedad;i++)
    {
    if (i==row) {
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), 2);
    }//taghiir rang baraye moshakhas kardan gozine fa'al
    cout<< i+1 <<"-"<<s.moton<<endl;
    if (i==row) {
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), 7);
    }//bargardandan rang be halat aval
    }
    return 0;//payan tabe
    }
    int main(){
    s.tedad=5; // moshakhas kardan tedad gozineha
    strcpy(s.moton[0],"Menu Viewer V 1.0");//kopy gozine aval
    strcpy(s.moton[1],"hellcrueldictator@yahoo.com");//kopy gozine 2vom
    strcpy(s.moton[2],"<a href="http://www.kitten.mihanblog.com%22%29;//kopy" target="_blank">www.kitten.mihanblog.com");//kopy</a> gozine 3vom
    strcpy(s.moton[3],"Kitten");//kopy gozine 4om
    strcpy(s.moton[4],"Movafagh bashid");//kopy gozine 5om
    strcpy(uptext[0],"this is my menu");//kopy matn balaye menu
    while(chi) {
    gotoxy(0,0); // shoro az ebteda
    menu(); // >>ejraye tabe menu
    ch =getch(); //up=72,down=80, enter=13
    switch(ch) {
    case 72://up
    if (row==0) {
    row=s.tedad-1;
    }//bargardandan be paiin
    else {
    row=row-1;
    }//bargardandan be bala
    break;
    case 80://down
    if(row==s.tedad-1) {
    row=0;
    }//bargardandan be bala
    else {
    row=row+1;
    }//bargardandan be paiin
    break;
    case 13://enter
    chi=false;//baraye khoroj az halghe
    break;

    }
    }
    /*baraye anjam karhaye badi
    gozineye entekhab shode tavasot karbar row+1 ast */
    return 0;
    }
    //shabih saz gotoxy
    void gotoxy(int x,int y)
    {
    COORD pos;
    HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
    if (INVALID_HANDLE_VALUE != hConsole)
    {
    pos.X = x;
    pos.Y = y;
    SetConsoleCursorPosition( hConsole, pos );
    }
    }

    [/TD]
    [/TR]
    [/TABLE]
     
  2. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    اینم دوتا کد دیگه
    اولی یه متن را اخر هر سطر فایل بازشده اضافه میکنه

    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    [/TD]
    [TD="class: code"]#include "stdafx.h"
    #include<fstream>
    using std::fstream;
    #include<iostream>
    #include<string.h>
    char pass[33];
    int n= 0;
    int m = 0;
    int y =0;
    fstream m2("c:\\2.txt");
    void neveshtan(char pass[32]) {
    m2<<pass<<"matn\n";
    }
    int main() {
    std::cout<<"tedad khotot?\n";
    std::cin>>y;
    fstream m1("c:\\1.txt");
    for (int x = 1; x<=y;x++) {
    m1.getline(pass,32);
    std::cout << pass << "\n";
    neveshtan(pass);
    _strset(pass,NULL);
    }
    return 0;
    }

    [/TD]
    [/TR]
    [/TABLE]



    و این هم دومی که از فایل 1.txt می خونه و ان سطرهایی که دقیقا مثل هم هستند را پاک میکنه تا متن های اضافی پاک بشه و فایلی که سطر تکراری نداره را به عنوان 2.txt ذخیره می کنه

    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    [/TD]
    [TD="class: code"]#include<iostream>
    using std::cin;
    using std::cout;
    using std::endl;
    #include<fstream>
    using std::fstream;

    #include<string.h>
    int khat;
    char id[33];
    int natije;
    char checkid[33];
    int cmp;
    char getid[33];
    int check(char checkid[33]) {
    fstream m3("c:\\2.txt");
    for (int j = 1; j <=khat;j++) {
    m3.getline(getid,32);
    cmp = strcmp(checkid,getid);
    if (cmp == 0) {
    cout<<checkid<<endl;
    return 0;
    }
    }
    return cmp;
    }
    int main () {
    fstream m2("c:\\2.txt");
    cout<<"tedad khotot?\n";
    cin >> khat;
    fstream m1("c:\\1.txt");
    for (int i = 1; i<=khat;i++) {
    m1.getline(id,32);
    natije = check(id);
    if (natije == 0) {
    continue;
    }
    else {
    m2<<id<<endl;
    }
    }
    return 0;
    }

    [/TD]
    [/TR]
    [/TABLE]
     
  3. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    عنوان: گرفتن ping سایت ها تنها با کلیک بر روی یک فایل

    این یک برنامه کوچک هست که در ویندوز پس از کامپایل باید از فایل اجرایی یک shortcut بسازید، سپس با راست کلیک کردن بر روی آن و انتخاب properties به قسمت Targets بروید. در آن مسیر فایل نوشته شده است، حال فقط کافیست آدرس وب سایت مورد نظر یا IP مورد نظر را در ادامه آن مثلا به شکل زیر داخل " " بنویسید. از این به بعد هرگاه بر روی این shortcut کلیک کنید پنجره کنسول باز می شود و سایت را ping می کند:(به تعداد مورد نظر نیز می توانید shortcut بسازید)
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    [/TD]
    [TD="class: code"]"E:\MyPingApp.exe" "ping www.yahoo.com"

    [/TD]
    [/TR]
    [/TABLE]


    برنامه در کامپایلرهای قدیمی و یا جدید اما در حالت اسکی:
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [/TD]
    [TD="class: code"]#include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>

    int main(int agrc, char *argv[])
    {
    system( argv[1] );

    getch();
    return 0;
    }

    [/TD]
    [/TR]
    [/TABLE]


    در حالت یونیکد (در کامپایلرهای جدید):
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    [/TD]
    [TD="class: code"]int _tmain(int argc, _TCHAR* argv[])
    {
    _tsystem( argv[1] );

    _getch();
    return 0;
    }

    [/TD]
    [/TR]
    [/TABLE]
     
  4. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    اطلاعات عمومی دانشجو

    خصوصیات برنامه:
    1)وارد کردن نمره به تعداد دلخواه
    2)بازه نمرات بین 0 تا 100
    3)مشخص کردن وضعیت نمرات
    4)گرفتن میانگین
    5)مشخص کردن تعداد افراد قبول و مردود شده

    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    [/TD]
    [TD="class: code"]#include <iostream.h>
    #include <conio.h>
    int main()
    {
    float x, counter=1, counterp=0, counterf=0,ave=0,y,m;
    cout<<"How many mark? ";
    cin>>y;
    cout<<"Pass and Fail: ";
    cin>>m;
    cout<<"#########################################";
    cout<<"\n";
    while (counter<=y){
    cout<<"Mark "<<counter<<": ";
    cin>>x ;
    counter=counter+1;
    ave+=x;
    if (x>100){
    cout<<"ERROR:FALSE MARK"<<"\n";
    cout<<"\n";
    cout<<"egain enter the ";
    counter=counter-1;
    }
    else if (x>=m){
    cout<<"Pass"<<"\n"<<"*********************"<<"\n"< <"\n";
    counterp+=1;
    }
    else{
    cout<<"Fail"<<"\n"<<"*********************"<<"\n"< <"\n";
    counterf+=1;
    }
    }

    if (counter=y){
    cout<<"Pass number: "<<counterp<<"\n";
    cout<<"Fail number: "<<counterf<<"\n";
    cout<<"Average: "<<ave/y<<endl;
    }

    getch();
    return 0;
    }

    [/TD]
    [/TR]
    [/TABLE]
     
  5. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    اوور لودینگ اپراتورها در کلاس در C++‎

    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    [/TD]
    [TD="class: code"]#include <iostream.h>
    #include <string.h>
    #include <conio.h>
    #include <stdio.h>
    class string
    {
    private:
    char text[40];
    public:
    void show()
    {
    cout << text << "\n";
    }
    string operator + (string s)
    {
    string temp;
    strcpy(temp.text, text);
    strcat (temp.text, s.text);
    return temp;
    }
    string operator + (char s[])
    {
    string temp;
    strcpy(temp.text, text);
    strcat (temp.text, s);
    return temp;
    }
    string operator++()
    {
    char temp[40];
    strcpy(temp , text);
    strcat(text,temp);
    }
    friend string operator +(char s[] , string s2)
    {
    string temp;
    strcpy(temp.text , s);
    strcat(temp.text , s2.text);
    return temp;
    }
    string operator =(char s[])
    {
    strcpy(text , s);
    }
    string operator =(string s)
    {
    strcpy(text , s.text);
    }
    };
    void main()
    {
    string s1 , s2 , s3;
    clrscr();
    s1 = "Ali";
    char temp[]={"Ali"};
    s2 = temp;
    s3 = "Hasan";
    s1++;
    s1.show(); //show = AliAli
    s1 = temp + s3;
    s1.show(); // show = AliHasan
    s2 = s1;
    s2.show(); //show = AliHasan
    s2 = s2 + "Majid";
    s2.show(); //show = AliHasanMajid
    getch();
    }

    [/TD]
    [/TR]
    [/TABLE]
     
  6. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    لیست پیوندی در زیان c به زبان ساده
    مختصات یک دایره را می گیرد و در لیست قرار می دهد
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    [/TD]
    [TD="class: code"]#include <stdio.h>
    #include <stdlib.h>
    struct circle
    {
    int x , y , r;
    circle *link;
    }*circlestart;
    //----------------------------------------------------------------------------
    int circleinsert()
    {
    circle *ptr;
    ptr = (circle*) malloc(sizeof(circle)); //creat a memmory for new item
    ptr->link = NULL;
    printf("Please Enter x y r seprated by space\n");
    int x , y , r;
    scanf("%d %d %d" , &x , &y , &r);
    ptr->x = x;
    ptr->y = y;
    ptr->r = r;
    if (circlestart == NULL) //if the list is empty put the new one on the first position
    {
    circlestart = ptr;
    return 0;
    }
    circle *p1;
    p1 = circlestart;
    while ( p1->link != NULL) //searches for the last item in the list
    {
    p1 = p1->link;
    }
    p1->link = ptr;
    return 0;
    }
    //----------------------------------------------------------------------------
    int circleshow()
    {
    if (circlestart == NULL) //if the list is empty
    {
    printf("No Circle Excist To Show\n");
    return 0;
    }
    circle *ptr;
    ptr = circlestart;
    while (ptr != NULL) //nevigate all of the list and print it
    {
    printf("X: %d Y: %d R: %d\n" , ptr->x , ptr->y , ptr->r);
    ptr = ptr->link;

    }

    return 0;

    }
    //----------------------------------------------------------------------------
    int circledelete()
    {
    if (circlestart == NULL)//if the list is empty
    {
    printf("No circles to delete\n");
    return 0;
    }
    int x , y ,r;
    printf("Please Enter x y r seprate by space to delete\n");
    scanf("%d %d %d" , &x , &y , &r);
    if (circlestart->x == x && circlestart->y == y && circlestart->r == r) //if the item is in the first position
    {
    circle *p;
    p = circlestart;
    circlestart = circlestart->link;
    free(p);
    printf("deleted\n");
    return 0;
    }
    circle *ptr , *preptr;
    ptr = circlestart;

    while (ptr->link != NULL) // nevigate all the list to find the item and delete it
    {
    preptr = ptr;
    ptr = ptr->link;
    if (ptr->x == x && ptr->y == y && ptr->r == r)
    {
    (*preptr).link = (*ptr).link;
    printf("deleted\n");

    free(ptr);
    return 0;
    }

    }
    printf("Not Found To Delete\n");
    return 0;

    }
    //----------------------------------------------------------------------------
    void menu()
    {
    printf("Please select an item with entering the number of it\n");
    printf("1- Creat a new circle\n");
    printf("2- Show circles\n");
    printf("3- Delete an exicting circle\n");
    printf("4- exit\n");
    }
    //----------------------------------------------------------------------------
    int main()
    {
    int key;
    do
    {
    menu();
    scanf("%d" , &key);
    switch(key)
    {
    case 1:
    circleinsert();
    break;
    case 2:
    circleshow();
    break;
    case 3:
    circledelete();
    break;
    case 4:
    return 0;
    }

    }while(1);
    return 0;
    }

    [/TD]
    [/TR]
    [/TABLE]
     
  7. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    عبارتهای جبری در c
    این برنامه عبارتهای جبری را می گیرد و نتیجه را نمایش می دهد:
    برای مثال عبارات زیر را وارد کنید و نتیجه را ببینید

    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    [/TD]
    [TD="class: code"]A*B/C-(D+F+G*(A-V)-D)
    A+B*C
    V-C+(((C*B-R)-E*F)/K-R+D^E)%N

    [/TD]
    [/TR]
    [/TABLE]


    و یا هر عبارت دیگری

    شاید نصف روز و یا بیشتر می نوشتمش
    نکاتی در مورد برنامه
    1- فاصله در بین عبارت مجاز نمی باشد
    2- استفاده از 2 حرف بین یک عملگر مجاز نمی باشد
    3- نمی توان عدد وارد کرد و باید حتماً حرف وارد کرد و وقتی حرف وارد کنیم معادل عددی آن را می گیرد
    4- ورودی آن تا 100 کاراکتر می باشد که می توان آن را در برنامه بیشتر کرد.
    5- پرانتز باز شده حتماً باید بسته شود
    6- در این برنامه از پشته استفاده شده و آن هم با لیست پیوندی
    7- امیدوارم مورد استفاده دوستان قرار بگیرد
    8- اگر نیاز به الگوریتم آن دارید و یا توضیحاتی راجع به آن می خواهید خبرم کنید
    با تشکر
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    [/TD]
    [TD="class: code"]#include <stdlib.h>
    #include <stdio.h>
    #include <math.h>
    #include <conio.h>
    #include <string.h>

    //************************** stack ****************************************
    struct stack
    {
    char info;
    stack *link;
    }*ss;
    //************************** stack ****************************************
    struct stack2
    {
    long info;
    stack2 *link;
    }*ss2;
    //************************** num ***************************************
    struct number
    {
    long value;
    char chr;
    number *link;
    }*ns;
    //************************** check num **********************************
    long checknum(char chr)
    {
    number *ptr;
    ptr = ns;
    while ( ptr != NULL)
    {
    if ( ptr->chr == chr) return ptr->value;
    ptr = ptr->link;
    }
    return 0;
    }
    //************************** insert num **********************************
    void insertnum(long value, char chr)
    {
    number *ptr;
    ptr = (number*) malloc(sizeof(number));
    ptr->link = ns;
    ptr->chr = chr;
    ptr->value = value;
    ns = ptr;
    }
    //************************** push ***************************************
    void push(char item)
    {
    stack *ptr;
    ptr = (stack*) malloc(sizeof(stack));
    ptr->info = item;
    ptr->link = ss;
    ss = ptr;
    }
    //************************** pop ****************************************
    char pop()
    {
    stack *ptr;
    ptr = ss;
    char temp;
    temp = ss->info;
    ss = ss->link;
    free(ptr);
    return temp;
    }
    //************************** push ***************************************
    void push2(long item)
    {
    stack2 *ptr;
    ptr = (stack2*) malloc(sizeof(stack2));
    ptr->info = item;
    ptr->link = ss2;
    ss2 = ptr;
    }
    //************************** pop ****************************************
    long pop2()
    {
    stack2 *ptr;
    ptr = ss2;
    long temp;
    temp = ss2->info;
    ss2 = ss2->link;
    free(ptr);
    return temp;
    }
    //************************** mid ****************************************
    char mid ( char source[] , int position , int count , char destination[])
    {
    int qcount = 0 , len ;
    len = strlen(source);
    for ( int i = position - 1 ; i < position + count - 1 && i < len ; i++ , qcount++)
    destination[qcount] = source;
    destination[qcount] = 0;
    if ( qcount == 1) return destination[0];
    else return 0;
    }
    //************************** priority **************************************
    int priority(char a , char b)
    {
    if ( a == '^') return 1;
    if ( b == '^') return 0;
    if ( a == '*' || a == '/' || a == '%' ) return 1;
    if ( b == '*' || b == '/' || b == '%' ) return 0;
    return 1;
    }
    //************************** pulish ****************************************
    void pulish(char source[] , char dest[] , int len)
    {
    char temp , temp2[2];
    int count = 0;
    for ( int i = 0 ; i < len ; i++)
    {
    temp = mid(source , i + 1 , 1 , temp2);
    switch (temp)
    {
    case '+':
    case '-':
    case '*':
    case '/':
    case '^':
    case '%':
    if (ss->info == '(' || priority(ss->info , temp) == 0 ) push (temp);
    else
    {
    while (ss ->info != '(' && priority(ss->info , temp))
    dest[count++] = pop();
    push(temp);
    }
    break;
    case '(':
    push(temp);
    break;

    case ')':
    while ( ss->info != '(')
    dest[count++] = pop();
    pop();
    break;
    default :
    if ( temp >= 48 && temp <= 122)
    dest[count++] = temp;
    }
    }
    dest[count] = 0;
    }
    //************************** value ****************************************
    long value(char source[] , int len)
    {
    char temp , temp2[2] ;
    long a , b, result;
    for ( int i = 0 ; i < len ; i++)
    {
    temp = mid ( source , i + 1 , 1 , temp2);
    if ( temp >= 48 && temp <= 122)
    {
    a = checknum(temp);
    if ( a == 0 )
    {
    printf("Please Enter %c =" , temp);
    scanf("%u" ,&a);
    insertnum(a , temp);
    push2(a);
    }
    else push2(a);
    }
    else
    {
    b = pop2();
    a = pop2();
    switch (temp)
    {
    case '+':
    result = a + b;
    push2 (result);
    break;
    case '-':
    result = a - b;
    push2 (result);
    break;
    case '*':
    result = a * b;
    push2 (result);
    break;
    case '/':
    result = a / b;
    push2 (result);
    break;
    case '^':
    result = pow(a,b);
    push2 (result);
    break;
    case '%':
    result = a % b;
    push2 (result);
    break;
    }
    }
    }
    return pop2();
    }
    //************************** main ****************************************
    int main()
    {
    char p[102] , q[100];
    clrscr();
    int len;
    scanf("%s" , p);
    len = strlen(p);
    for ( int i = len ; i > 0 ; i--)
    p = p[i-1];
    p[0] = '(';
    p[len + 1] = ')';
    len +=2;
    p[len] = 0;
    pulish ( p , q , len);
    len = strlen(q);
    printf("\n%u\n" , value ( q , len));
    getch();
    return 0;
    }

    [/TD]
    [/TR]
    [/TABLE]
     
  8. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    این کد واسه کامپایل با کامپایلر نیست ماله اینکه خودوتون ببینین و خروجی را بدین!! واسه تمرین درک :
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    [/TD]
    [TD="class: code"]/* Practice-Win32.cpp : Defines the entry point for the console application.
    Coded by ace.coder in Visual(C++‎) Studio 2008 ; { Friday , December 19 , 2008 2:11 AM }
    Example #1 - TOO EASY
    Our Question -> This Program IF IN RUN HAVE A TRUE OUTPUT? , For Everybody Call To Himself ELITE.
    ( WithOut By Compiler , just read/write on paper and Trace )
    Good Luck
    */
    #include "stdafx.h"
    #include <iostream>
    #include <conio.h>
    using namespace std;
    static char Z;
    int main(int argc, char* argv[])
    {

    ;char joomla[20]="AAce.Coder88"
    ;{Z='\0';}char temp[20]="AAce.Coder"
    ;int i=0
    ;int counter=0
    ;joomla[*(temp + *(joomla))]=88
    ;for (;i<20;i++,counter++)
    if ( joomla==*(temp+counter)&&joomla!=Z)
    cout<<joomla<<" : YES"<<endl
    ;{getch();}
    ;return 0
    ;}

    [/TD]
    [/TR]
    [/TABLE]
     
  9. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    این الگوریتم کلی و سورس کامل مثلث n عددی:
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    [/TD]
    [TD="class: code"]#include <iostream.h>
    int cNum (int k)
    {
    int val =1;
    while( k/10 > 0 )
    {
    k /=10;
    val ++;
    }
    return val;
    }
    int cNumCount (int k)
    {
    int val = 0;
    for( int i=k; i>0 && cNum(i)== cNum(k); i--)
    val ++;
    return val;
    }
    int main()
    {
    int n, c, b, j;
    cout<<"\n add ro vared konid >";
    cin>>n;
    c = n*2;
    b = 1;
    for(int i=0;i<n;i++){
    cout<<"\n";
    for(j=0;j<c-i-cNumCount(b)*(cNum(i)-1);j++)
    cout<<" ";
    for( j=1;j<=b;j++)
    cout<<j;
    for( j=1;j<i+cNum(i);j++)
    cout<<j;
    b+=1;
    }
    return 0;
    }

    [/TD]
    [/TR]
    [/TABLE]
     
  10. کاربر ارشد

    تاریخ عضویت:
    ‏6/9/12
    ارسال ها:
    14,318
    تشکر شده:
    2,702
    امتیاز دستاورد:
    0
    حرفه:
    daneshjo
    پاسخ : مجموعه برنامه های نوشته شده به زبان C و ++C

    برنامه ای که داخل فایل(Data.Txt) کلمه ای رو که بیشترین تکرار رو داشته باشه رو برمیگردونه.
    [TABLE]
    [TR]
    [TD="class: gutter"]1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    [/TD]
    [TD="class: code"]#include "iostream.h"
    #include "stdio.h"
    #include "stdlib.h"
    #include "conio.h"
    void main()
    {
    clrscr();
    FILE *f1;
    struct txt
    {
    char name[20];
    int rep;
    }list[10];
    f1=fopen("Data.txt","rb");
    for(int i=0;i<10;i++)
    list.rep=0;
    int j=0;
    char A[20];
    while(f1 != NULL && !feof(f1))
    {
    fscanf(f1,"%s",&A);
    for(int i=0;i<j;i++)
    if( strcmp(list.name, A)==0 ){
    list.rep++;
    break;
    }else{
    strcpy(list[j].name, A);
    list[j].rep = 1;
    }
    j++;
    }
    fclose(f1);
    int max=0;
    for(int k=1;k<10;k++)
    if(list[k].rep>list[max].rep)
    max=k;
    cout<<list[max].name;
    getch();
    }

    [/TD]
    [/TR]
    [/TABLE]