Skip to content

Instantly share code, notes, and snippets.

@juanfal
Created November 28, 2022 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanfal/c9978cbaa418114639f80f6572dcbbb2 to your computer and use it in GitHub Desktop.
Save juanfal/c9978cbaa418114639f80f6572dcbbb2 to your computer and use it in GitHub Desktop.
freqs of digits 0 9
// 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