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

📄 soln3_1b.cpp

📁 Wrox.Ivor.Hortons.Beginning.Visual.C.Plus.Plus.2008 With sourcecode
💻 CPP
字号:
// Soln3_1B.cpp

/* Here the check for val being zero is at the end of the loop.
   You read val in the loop and add the value to total. If value 
   read into val was zero the loop ends.
*/

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main()
{
   int val, total=0;
   cout << "Enter numbers, one per line. Enter 0 to end:\n";

   do
   {
      cin >> val;
      total += val;
   } while (val != 0);

   cout << "\nThank you. The total was " << total;
   cout << endl;
   return 0;
}

⌨️ 快捷键说明

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