kmitl-profund-exercise/character-counter/main.cpp

23 lines
486 B
C++
Raw Permalink Normal View History

2023-04-02 18:01:59 +00:00
#include<stdio.h>
#include<iostream>
int main() {
char input[10000];
int chars[26],i=0;
for(int j=0;j<26;j++)chars[j]=0;
printf("Input: ");
std::cin >>input;
while(input[i]!='\0') {
if(input[i]>=65&&input[i]<=90){
chars[(int)input[i]-65]++;
}
else if(input[i]>=97&&input[i]<=122){
chars[(int)input[i]-97]++;
}
i++;
}
for(i=0;i<26;i++) printf("%c : %d\n", i+65, chars[i]);
return 0;
}