Created
November 28, 2022 11:30
-
-
Save juanfal/c9978cbaa418114639f80f6572dcbbb2 to your computer and use it in GitHub Desktop.
freqs of digits 0 9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// freqsInt09.cpp | |
// juanfc 2022-11-28 | |
// | |
#include <iostream> | |
#include <array> | |
using namespace std; | |
const int N = 10; | |
typedef array<int,N> TFreqs09; | |
int main() | |
{ | |
void init(TFreqs09&); | |
void printFreqs(TFreqs09); | |
TFreqs09 arr; | |
init(arr); | |
int dig; | |
while (cin >> dig and dig != -1) | |
arr[dig]++; | |
printFreqs(arr); | |
return 0; | |
} | |
void printFreqs(TFreqs09 f) | |
{ | |
for (int i = 0; i < N; ++i) | |
cout << i << ":" << f[i] << " "; | |
cout << endl; | |
} | |
void init(TFreqs09& a) | |
{ | |
for (int i = 0; i < N; ++i) | |
a[i] = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment