OAIP/21-22/21.c
2024-11-22 21:00:20 +04:00

110 lines
1.6 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "stdio.h"
#include "Windows.h"
int isDigit(char);
char toUpperCase(char);
int main1() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
printf("Ââåäèòå ñèìâîë: ");
char ch = ' ';
scanf_s("%c", &ch);
printf("Çàäà÷à 1\n");
for (int i = ch; i <= ch + 19; i++) {
printf("%c, %d\n", i, i);
}
printf("\nÇàäà÷à 2\n");
for (int i = ch; i >= ch - 29; i--) {
printf("%c, %d\n", i, i);
}
printf("\nÇàäà÷à 3\n");
char str[100];
int k = 0;
scanf_s(" %[^\n]", &str, 100);
printf("%s\n", str);
for (int i = 0; i < strlen(str); i++)
if (str[i] == ' ') k++;
printf("êîëè÷åñòâî ïðîáåëîâ = %d\n", k);
printf("\nÇàäà÷à 4\n");
scanf_s(" %[^\n]", &str, 100);
printf("%s\n", str);
for (int i = 0; i < strlen(str); i++)
if (str[i] == ' ') str[i] = '#';
printf("%s\n", str);
printf("\nÇàäà÷à 5\n");
scanf_s(" %[^\n]", &str, 100);
printf("%s\n", str);
for (int i = 0; i < strlen(str); i++)
if (isDigit(str[i])) str[i] = '$';
printf("%s\n", str);
printf("\nÇàäà÷à 6\n");
scanf_s(" %[^\n]", &str, 100);
printf("%s\n", str);
for (int i = 0; i < strlen(str); i++)
str[i] = toUpperCase(str[i]);
printf("%s\n", str);
printf("\nÇàäà÷à 9 Â8\n");
scanf_s(" %[^\n]", &str, 100);
printf("%s\n", str);
for (int i = 0; i < strlen(str); i++)
if(!(str[i] >= 'a' && str[i] <= 'z' || str[i] >= 'A' && str[i] <= 'Z'))
str[i] = '_';
printf("%s\n", str);
return 0;
}
int isDigit(char c) {
return c > '0' && c <= '9';
}
char toUpperCase(char c) {
if (c >= 'a' && c <= 'z') return 'A' + (c - 'a');
if (c == '¸') return '¨';
return c;
}