تبلیغات :
آکوستیک ، فوم شانه تخم مرغی، صداگیر ماینر ، یونولیت
دستگاه جوجه کشی حرفه ای
فروش آنلاین لباس کودک
خرید فالوور ایرانی
خرید فالوور اینستاگرام
خرید ممبر تلگرام

[ + افزودن آگهی متنی جدید ]




صفحه 1 از 2 12 آخرآخر
نمايش نتايج 1 به 10 از 16

نام تاپيک: تبدیل c به c++

  1. #1
    داره خودمونی میشه abdolhakim's Avatar
    تاريخ عضويت
    Sep 2010
    پست ها
    161

    پيش فرض تبدیل c به c++

    سلام دوستان
    حالتون خوبه ؟ خب خدا رو شکر
    من کد برنامه C دارم میخام تبدیلش کنم به ++C
    آگه کسی میدونه چطور میشه اینکارو انجام بدم لطف کنه بگه

  2. #2
    حـــــرفـه ای A M ! N's Avatar
    تاريخ عضويت
    Dec 2009
    محل سكونت
    Under the weeping moon
    پست ها
    7,118

    پيش فرض

    سلام..ما که خوبیم شمام خوبی ؟
    سورسهای C رو میشه با کامپایلر ++ C اجرا کرد در حالی که بالعکس رو نمیشه.

    با کامپایلر ++ C سورس رو run کردین ؟ از Borland استفاده کنید. ببینید چی میشه ولی برای تبدیل کامل فرمت سورس از لینک پایین استفاده کنید :

    [ برای مشاهده لینک ، با نام کاربری خود وارد شوید یا ثبت نام کنید ]

    حتما Manual رو هم بخونین که بدونین باید چیکار کنید، مثلا برای اجرای اسکریپت گفته شده که به Python هم نیاز هستش.
    Last edited by A M ! N; 28-05-2012 at 03:01.

  3. این کاربر از A M ! N بخاطر این مطلب مفید تشکر کرده است


  4. #3
    آخر فروم باز Ghaioom's Avatar
    تاريخ عضويت
    Dec 2007
    محل سكونت
    ترکمن صحرا
    پست ها
    6,385

    پيش فرض

    سلام. ما خوبیم شما چی در سلامتی کامل به سر میبری هو؟!

    آنچنان فرقی بین کدهای همدیگه ندارن. مثلا گاهی کدهاش رو مثلا پرینت بود فک کنم من cout مثل اینکه کرده بودمش کار کرد.
    یادم نیست بقیه ولی میشد دستی درست کرد.
    شاید کد رو بزارین ببینیم بشه گفت.

  5. این کاربر از Ghaioom بخاطر این مطلب مفید تشکر کرده است


  6. #4
    داره خودمونی میشه abdolhakim's Avatar
    تاريخ عضويت
    Sep 2010
    پست ها
    161

    پيش فرض

    سلام..ما که خوبیم شمام خوبی ؟
    سورسهای C رو میشه با کامپایلر ++ C اجرا کرد در حالی که بالعکس رو نمیشه.

    با کامپایلر ++ C سورس رو run کردین ؟ از Borland استفاده کنید. ببینید چی میشه ولی برای تبدیل کامل فرمت سورس از لینک پایین استفاده کنید :

    [ برای مشاهده لینک ، با نام کاربری خود وارد شوید یا ثبت نام کنید ]

    حتما Manual رو هم بخونین که بدونین باید چیکار کنید، مثلا برای اجرای اسکریپت گفته شده که به Python هم نیاز هستش.
    داش من خوندم چیزی حالیم نشد

    اگه سورس بدم شما میتونید اوک کنید ؟

  7. #5
    حـــــرفـه ای A M ! N's Avatar
    تاريخ عضويت
    Dec 2009
    محل سكونت
    Under the weeping moon
    پست ها
    7,118

    پيش فرض

    آخه چرا داداش ؟
    سورس رو بزار ، یه فکری به حالش میکنیم

  8. این کاربر از A M ! N بخاطر این مطلب مفید تشکر کرده است


  9. #6
    داره خودمونی میشه abdolhakim's Avatar
    تاريخ عضويت
    Sep 2010
    پست ها
    161

    پيش فرض

    بیا داداش اینم سورس

    #include<iostream>
    #include<string.h>
    using namespace std;
    class Car{
    /*this is the definition of our class*/
    public:
    char make[100];
    char model[100];
    int partno;
    char partName[100];
    float price;
    int quantity;
    void car(char* make1,char* model1, int partno1, char* partName1, float price1, int quantity1) {
    strcpy(make,make1);
    strcpy(model,model1);
    partno=partno1;
    strcpy(partName,partName1);
    price=price1;
    quantity=quantity1;
    }
    };
    int show(){
    int k=0;
    cout<<"[1] Add part\n[2] Update part\n[3] Remove part\n[4] List inventory\n[5] Parts whose quantity < 5\n[6] Parts above a given price\n[7] Parts above the average price\n[8] Stock statistics\n[9] Exit\n\n\n\nEnter your choice: ";
    cin>>k;
    cout<<"\n";
    return k;
    }
    void reloadfile(int count, Car* car_object){
    FILE * fout=fopen("inventory.txt", "w");
    //make model partNo Quantity price partName
    fprintf(fout,"make model partNo Quantity price partName\n");
    for(int i=0;i<count;i++){
    if(car_object[i].partno>0){
    fprintf(fout,"%s ",car_object[i].make);
    fprintf(fout,"%s ",car_object[i].model);
    fprintf(fout,"%d ",car_object[i].partno);
    fprintf(fout,"%d ",car_object[i].quantity);
    fprintf(fout,"%f ",car_object[i].price);
    fprintf(fout,"%s",car_object[i].partName);
    }
    }
    fclose(fout);
    }
    int loadfile(Car * car_object){
    char make2[100];
    char model2[100];
    int partno2;
    char partName2[100];
    float price2;
    int quantity2;
    int count=0;
    /*
    make model partNo Quantity price partName
    Pajero NA1H25 1 26 3.65 BLADE W/S WIPER
    */
    FILE * fin =fopen("inventory.txt","r");
    char str[100];
    fgets(str,100,fin);
    //printf("%s",str);
    while(fgets(str,100,fin)!=NULL){
    char * pch;
    pch = strtok (str," ");
    strcpy(make2,pch);
    pch = strtok (NULL, " ");
    strcpy(model2,pch);
    pch = strtok (NULL, " ");
    partno2=atoi(pch);
    pch = strtok (NULL, " ");
    quantity2=atoi(pch);
    pch = strtok (NULL, " ");
    price2=atof(pch);
    pch = strtok (NULL, "");
    strcpy(partName2,pch);
    car_object[count].car(make2,model2,partno2,partName2,price2,quantit y2);
    count++;
    }
    return count;
    }
    void updateItem(int count,Car * car_object){
    cout<<"please Enter A,a/R,r if you want to add or remove\n";
    char x;
    cin>>x;

    if(x=='A'||x=='a'){
    cout<<"Please Enter Partnumber : ";
    int numa,numb;
    cin>>numa;
    cout<<"\nHow many items do you want to add?\n";
    cin>>numb;
    for(int i=0;i<count;i++){
    if(car_object[i].partno==numa){
    car_object[i].quantity+=numb;
    }
    }
    }
    else if(x=='R'||x=='r')
    {
    cout<<"Please Enter Partnumber : ";
    int numa,numb;
    cin>>numa;
    cout<<"\nHow many items do you want to remove?\n";
    cin>>numb;
    for(int i=0;i<count;i++){
    if(car_object[i].partno==numa){
    if(car_object[i].quantity > numb){
    car_object[i].quantity-=numb;
    }
    else{
    cout<<"Sorry ... this action is impossible\n";
    cin>>x;

    }
    }
    }
    }
    reloadfile(count,car_object);
    }
    int addItem(int count,Car * car_object){
    char make2[100];
    char model2[100];
    int partno2;
    char partName2[100];
    float price2;
    int quantity2;
    cout<<"Stock Control _ Add Item:\n=========================\n";
    cout<<"Enter the car make : ";
    cin>>make2;
    cout<<"Enter the car model : ";
    cin>>model2;
    cout<<"Enter partNo: ";
    cin>>partno2;
    cout<<"Enter part name: ";
    cin>>partName2;
    cout<<"Enter price: ";
    cin>>price2;
    cout<<"Enter quantity: ";
    cin>>quantity2;
    car_object[count].car(make2,model2,partno2,partName2,price2,quantit y2);
    cout<<"Save (Y,a/N,n): ";
    char x;
    cin>>x;
    if(x=='Y'||x=='y'){
    cout<<".....Record saved.\n";
    count++;
    }
    else if (x=='N'||x=='n')
    {
    cout<<".....Record cancelled.\n";
    }
    else
    cout<<"You did not entered either N,n or Y,y:";
    reloadfile(count,car_object);
    return count;
    }
    void list(int count,Car * car_object, int quant, float pri){
    //make model partNo Quantity price partName
    cout<<"make model partNo Quantity price partName Total_price\n";
    for(int i=0;i<count;i++){
    if(car_object[i].partno>0 && car_object[i].quantity<quant && car_object[i].price>pri){
    cout<<car_object[i].make;
    cout<<car_object[i].model;
    cout<<car_object[i].partno;
    cout<<car_object[i].quantity;
    cout<<car_object[i].price;
    cout<<car_object[i].partName;
    cout<<car_object[i].price*car_object[i].quantity;
    }
    }
    }
    void remove(int count, Car * car_object){
    cout<<"please Enter your part number to Remove it :";
    int num;
    cin>>num;
    for(int i=0;i<count;i++){
    if(car_object[i].partno==num){
    car_object[i].partno=-1;
    }
    }
    reloadfile(count,car_object);
    }
    void statistics(int count, Car * car_object){
    /*
    Stock statistics such as: the current value of the stock (sum of price*quantity),
    the average price, the most expensive item, the least expensive item, the least
    stocked item … etc.
    */
    int number=0,least=100000;
    float sum=0,avg=0,highprice=-1,cheapprice=1000000;
    for (int i=0;i<count;i++){
    if(car_object[i].partno>0){
    sum+= (car_object[i].quantity*car_object[i].price);
    avg+=car_object[i].price;
    number++;
    if(car_object[i].price<cheapprice){
    cheapprice=car_object[i].price;
    }
    if(car_object[i].price>highprice){
    highprice=car_object[i].price;
    }
    if(car_object[i].quantity<least){
    least=car_object[i].quantity;
    }
    }
    }
    avg=avg/number;
    printf("the current value of the stock (sum of price*quantity)= %f\nthe average price: %f\nthe most expensive item: %f\nthe least expensive item : %f\nthe leaststocked item :%d \n",sum,avg,highprice,cheapprice,least);
    char x;
    cin>>x;
    }
    void control(){
    Car car_object[1000];
    int count=loadfile(car_object);
    int option;
    while(1){
    option=show();
    if(option==1){
    /*
    Add a new item. Write a function called addItem() that asks the user to input data of a
    new part and then add the data to the parts file (keeping the same file format).
    */
    count=addItem(count,car_object);
    }
    else if(option==2){
    /*Update stock level. Write a function called updateItem() that takes as parameter the
    partNo and the quantity to be added/removed. Check that enough items are there if the
    operation is a remove operation.
    */
    updateItem(count,car_object);
    }
    else if(option==3){
    /*
    Remove an item. You cannot remove an array element. However, let us use a negative
    partNo to indicate a removed item. When saving the arrays to the file, only save items
    with positive partNo.
    */
    remove(count,car_object);
    }
    else if(option==4){
    /*
    List the current inventory in a tabular format. In the last column of this list show the
    total price of each item (i.e. price*quantity).
    */
    list(count,car_object,1000000,-1);
    }
    else if(option==5){
    /* All items whose quantity field < 5.*/
    list(count,car_object,5,-1);
    }
    else if(option==6){
    /*All items whose price is greater than a value provided by the user.*/
    cout<<"Enter you price amount\n";
    float f;
    cin>>f;
    list(count,car_object,1000000,f);
    }
    else if(option==7){
    /* All items whose price is greater than the average item price.*/
    float avg=0;
    int number=0;
    for(int i=0;i<count;i++){
    if(car_object[i].partno>0){
    avg+=car_object[i].price;
    number++;
    }
    }

    avg=avg/number;
    list(count,car_object,1000000,avg);
    cout<<"avg and num = %f , %d \n"<<avg<< number;
    }
    else if(option==8){
    /*
    Stock statistics such as: the current value of the stock (sum of price*quantity),
    the average price, the most expensive item, the least expensive item, the least
    stocked item … etc.
    */
    statistics(count,car_object);
    }
    else if(option==9){
    /*EXIT*/
    return ;
    }
    }
    }
    int main(){
    /*this function manages every thing*/
    control();
    return 0;
    }

  10. #7
    حـــــرفـه ای A M ! N's Avatar
    تاريخ عضويت
    Dec 2009
    محل سكونت
    Under the weeping moon
    پست ها
    7,118

    پيش فرض

    سلام.

    این سورس پایین رو حالا با ++ Dev C امتحان کن:



    پسوند رو هم به CPP تغییر بده..

    بهترین آرزوها..
    Last edited by A M ! N; 29-05-2012 at 01:54.

  11. 3 کاربر از A M ! N بخاطر این مطلب مفید تشکر کرده اند


  12. #8
    آخر فروم باز Ghaioom's Avatar
    تاريخ عضويت
    Dec 2007
    محل سكونت
    ترکمن صحرا
    پست ها
    6,385

    پيش فرض

    عزیز چقد زیاد بود ما فک کردیم کمه!!

    بعدشم این خودش فک کنم c++ هست. نیست؟!
    کداش که چنین میگه.

  13. 2 کاربر از Ghaioom بخاطر این مطلب مفید تشکر کرده اند


  14. #9
    حـــــرفـه ای A M ! N's Avatar
    تاريخ عضويت
    Dec 2009
    محل سكونت
    Under the weeping moon
    پست ها
    7,118

    پيش فرض

    فایل Exe سورس ++C:


    ....................... [ برای مشاهده لینک ، با نام کاربری خود وارد شوید یا ثبت نام کنید ]



    بهترین آرزوها..
    Last edited by A M ! N; 29-05-2012 at 13:49.

  15. این کاربر از A M ! N بخاطر این مطلب مفید تشکر کرده است


  16. #10
    در آغاز فعالیت
    تاريخ عضويت
    May 2012
    پست ها
    3

    پيش فرض

    ممنون از سایت خوبتون

صفحه 1 از 2 12 آخرآخر

Thread Information

Users Browsing this Thread

هم اکنون 1 کاربر در حال مشاهده این تاپیک میباشد. (0 کاربر عضو شده و 1 مهمان)

User Tag List

قوانين ايجاد تاپيک در انجمن

  • شما نمی توانید تاپیک ایحاد کنید
  • شما نمی توانید پاسخی ارسال کنید
  • شما نمی توانید فایل پیوست کنید
  • شما نمی توانید پاسخ خود را ویرایش کنید
  •