?? histogram.cpp
字號:
// simple histogramming program
#include <iostream>
using namespace std;
void main(void)
{// Histogram of nonnegative integer values.
int n, // number of elements
r; // values between 0 and r
cout << "Enter number of elements and range"
<< endl;
cin >> n >> r;
// create histogram array h
int *h = new int[r+1];
// initialize array h to zero
for (int i = 0; i <= r; i++)
h[i] = 0;
// input data and compute histogram
for (i = 1; i <= n; i++)
{// assume input values are between 0 and r
int key; // input value
cout << "Enter element " << i << endl;
cin >> key;
h[key]++;
}
// output histogram
cout << "Distinct elements and frequencies are"
<< endl;
for (i = 0; i <= r; i++)
if (h[i] != 0)
cout << i << " " << h[i] << endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -