⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debugging02.cpp

📁 C++上机课的习题答案
💻 CPP
字号:
// Debugging problem
//双重循环,对两个循环变量的每组取值进行各种运算。
//注意:i,j最后的值。 
#include <iostream>

using std::cout;
using std::endl;

#include <iomanip>

using std::setprecision;

int main()
{
   int i = 1;
   double a;
   double b;

   cout << setprecision( 2 );

   for ( int i; i <= 2; i++ )
      cout << "i is now equal to " << i << endl;

      for ( int j; j <= 3; j++ ) {
         cout << "\tj is now equal to " << j << endl;

         cout << "\t\ti + j = " << i + j << "\ti - j = "
              << i - j << endl;
         cout << "\t\ti * j = " << i * j << "\ti ^ j = "
              << pow( i, j ) << endl;
         
         if ( j = 0 )
            continue;

         else {
            a = i;
            b = j;
            cout << "\t\ti / j = " << a / b
                    "\ti % j = " << a % b << endl;
         } // end else

      } // end for

   cout << "\nThe final values of i and j are: " << i
        << " and " << j << endl;

   system("PAUSE");
   return 0;

} // end main


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -