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

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




نمايش نتايج 1 به 2 از 2

نام تاپيک: کسی میتونه error های این برنامه رو اصلاح کنه؟

  1. #1
    در آغاز فعالیت elham_r1366's Avatar
    تاريخ عضويت
    Mar 2007
    محل سكونت
    semnan
    پست ها
    1

    پيش فرض کسی میتونه error های این برنامه رو اصلاح کنه؟

    // Chapter 4 of C++ How to Program
    // sales.cpp
    #include <iostream>
    using std::cout;
    using std::cin;
    using std::endl;
    using std::ios;
    #include <iomanip>
    using std::setiosflags;
    using std::setprecision;
    using std::setw;
    int main()
    {
    const int PEOPLE = 5, PRODUCTS = 6;
    /* Write the declaration for array sales here */
    double value, totalSales,
    productSales[ PRODUCTS ] = { 0.0 };
    int salesPerson, product;

    cout << "Enter the sales person (1 - 4), "
    << "product number (1 - 5)\nand total sales."
    << "Enter -1 for the sales person to end input.\n";
    cin >> salesPerson;

    while ( salesPerson != -1 ) {
    cin >> product >> value;
    /* Write a statement that adds values to the
    sales array */
    cin >> salesPerson;
    }
    // table header: describes output and prints
    // column header(product numbers 1-5)
    cout << "\nThe total sales for each sales person "
    << "are displayed\nat the end of each row,"
    << "and the total sales for each\nproduct "
    << "are displayed at the bottom of each column.\n"
    << setw( 10 ) << 1 << setw( 10 ) << 2
    << setw( 10 ) << 3 << setw( 10 ) << 4
    << setw( 10 ) << 5 << setw( 12 ) << "Total\n"
    << setiosflags( ios::fixed | ios::showpoint );
    // nested loop structure: prints salesperson number
    // followed by the amounts sold for each product
    for ( int i = 1; /* Write condition here */ ; ++i ) {
    totalSales = 0.0;
    // this prints salesperson number
    cout << i;

    // inner loop: prints amounts sold for each product
    for ( int j = 1; /* Write condition here */ ;
    ++j ) {
    /* Write a statement that adds the current sales
    element to totalSales */
    // print sales for each salesperson for each product
    cout << setw( 10 ) << setprecision( 2 )
    << sales[ i ][ j ];
    /* Write a statement that adds the current sales
    element to productSales */
    }
    // print the last column item (total sales of each
    // product). The totalSales value is 9.99 under
    // "Total" in the output box. After this value is
    // printed, the next table line can be created
    cout << setw( 10 ) << setprecision( 2 )
    << totalSales << '\n';
    }

    // this is the header for the last row
    cout << "\nTotal" << setw( 6 ) << setprecision( 2 )
    << productSales[ 1 ];
    // this prints the last row which displays the total sales
    // for each product
    for ( int j = 2; j < PRODUCTS; ++j )
    cout << setw( 10 ) << setprecision( 2 )
    << productSales[ j ];
    cout << endl;
    return 0;
    }

    /************************************************** ************************
    * (C) Copyright 2002 by Deitel & Associates, Inc. and Prentice Hall. *
    * All Rights Reserved. *
    * *
    * DISCLAIMER: The authors and publisher of this book have used their *
    * best efforts in preparing the book. These efforts include the *
    * development, research, and testing of the theories and programs *
    * to determine their effectiveness. The authors and publisher make *
    * no warranty of any kind, expressed or implied, with regard to these *
    * programs or to the documentation contained in these books. The authors *
    * and publisher shall not be liable in any event for incidental or *
    * consequential damages in connection with, or arising out of, the *
    * furnishing, performance, or use of these programs. *
    ************************************************** ***********************/

  2. #2
    آخر فروم باز hamidreza_buddy's Avatar
    تاريخ عضويت
    Sep 2004
    محل سكونت
    شریف
    پست ها
    1,167

    پيش فرض

    میگه که sales تعریف نشده. این تمرین ناقص نوشته شده و باید خود شما کاملش کنی.
    خودش هم comment گذاشته که کجاهاشو باید کامل کنی.
    مثلاً:
    کد:
    برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید
    و یا
    کد:
    برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید
    و یا
    کد:
    برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید

Thread Information

Users Browsing this Thread

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

User Tag List

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

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