Write a function that counts the occurrences of each digit in the string using the following header:
int * count(const string &s)
This function returns the counts as an array of 10 elements. For example, after invoking
int counts[] = count("2312ABcaB2")
counts[0] is 0, counts[1] is 1, and counts[2] is 3, etc.
```
#include
#include
using namespace std;
int* countLetters(string &s)
{
int* counts = new int[10];
for (int i = 0; i < 10; i++)
counts[i] = 0;
for (unsigned i = 0; i < s.size(); i++)
{
if (isdigit(s[i]))
counts[tolower(s[i]) - '0'] ++;
}
return counts;
}
int main()
{
string s = "001120191";
int* counts = countLetters(s);
for (int i = 0; i < 10; i++)
cout << (char)(i + '0') << " appears " << counts[i] << " times" << endl;
return 0;
}
```
You might also like to view...
Which of the following display types are most likely to have "burn-in" due to uneven phosphor wear?
a. Plasma b. LCD-CCFL c. LCD-LED d. DLP
What is the meaning of number "0" in this following formula: =VLOOKUP(F1,A1:B10,2,0)
a. Finding the relative value in F1 b. It does not have any meaning, just a part of the VLOOKUP syntax. c. Finding the exact value in F1 d. Finding the position value of number Zero in A1:B10
The security administrator receives an email on a non-company account from a coworker stating that some reports are not exporting correctly. Attached to the email was an example report file with several customers' names and credit card numbers with the PIN.Which of the following is the BEST technical controls that will help mitigate this risk of disclosing sensitive data?
A. Configure the mail server to require TLS connections for every email to ensure all transport data is encrypted B. Create a user training program to identify the correct use of email and perform regular audits to ensure compliance C. Implement a DLP solution on the email gateway to scan email and remove sensitive data or files D. Classify all data according to its sensitivity and inform the users of data that is prohibited to share
The ______________ imaging tool produces three proprietary formats: IDIF, IRBF, and IEIF.
Fill in the blank(s) with the appropriate word(s).