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

📄 00054.cpp

📁 通过一些基础的程序
💻 CPP
字号:
/*
名称编号:00054
实现功能:打印历史图表
运行结果:通过
*/
/***************************************************************************/

#include <iostream>

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

#include <iomanip>

using std::setw;

int main()
{
   const int arraySize = 10;
   int n[ arraySize ] = { 19, 3, 15, 7, 11, 9, 13, 5, 17, 1 };

   cout << "Element" << setw( 13 ) << "Value"
        << setw( 17 ) << "Histogram" << endl;

   // for each element of array n, output a bar in histogram
   for ( int i = 0; i < arraySize; i++ ) 
		{
			cout<<setw(7)<<i<<setw( 13 ) 
				<<n[i]<<setw(9);
			for (int j=0;j<n[i];j++)   // print one bar
				cout << '*';
			cout<<endl;  // start next line of output
		} // end outer for structure

   return 0;  // indicates successful termination

} // end main

/**************************************************************************
Element        Value        Histogram
      0           19        *******************
      1            3        ***
      2           15        ***************
      3            7        *******
      4           11        ***********
      5            9        *********
      6           13        *************
      7            5        *****
      8           17        *****************
      9            1        *
**************************************************************************/

⌨️ 快捷键说明

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