'How to work with Ukrainian (or Russian) letters in C language?
Good day to all))
The task is as follows: "Enter the entered Ukrainian (or Russian) sentences into a singly linked list organized as a queue (only addresses should be stored in the list, and the sentences themselves should be placed separately in memory). Determine the sentence in which the largest number of different Ukrainian letters is used (or Russian) alphabet, and make this sentence the first in the list. And exclude the sentence in which the least different letters are from the list. Develop a function that determines the number of different letters used in a given character string."
I have a program for finding different letters and it works correctly, but only with the English alphabet. Does anyone have ideas how remake it for work with the Ukrainian/Russian alphabet?
There is an idea to create an array with the letters of the Ukrainian alphabet and already look for different letters in the sentence in this way (that is, if the letter in the sentence corresponds to the letter from the array, then make certain actions). What think about it?
Thank you all in advance for your help :)
The code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define ASCII 128
int main(void){
system("chcp 1251");
char s[BUFSIZ];
int freq[ASCII] = { 0 };
size_t i, len_s;
unsigned int count;
printf("Input sentence: ");
gets_s(s, BUFSIZ - 1);
len_s = strlen(s);
for (i = 0; i < len_s; i++)
if (isalpha(s[i]))
freq[s[i]]++;
count = 0;
for (i = 0; i < ASCII; i++) // i = 65
if ((isalpha(i)) && (freq[i] > 0))
count++;
printf("\nDifferent chars: %u", count);
printf("\n\n");
system("pause");
return EXIT_SUCCESS;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
