forked from Maria02179/mp1-2020-382003-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
strNum6.1.c
75 lines (73 loc) · 1.37 KB
/
strNum6.1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <malloc.h>
#include < string.h >
#include <Windows.h>
#include <stdbool.h>
#include <assert.h>
//#include <wchar.h>
//#include <wctype.h>
int Pos(char key) {
char Rus[] = "àáâãäååæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
int i = 0;
char Key = tolower(key);
while (Rus[i] != Key)
{
i++;
}
return i;
}
bool Tab(char key) {
char tab[] = "?.,! ";
bool flag = true;
int i;
for (i = 0; i < 5; i++) {
if (tab[i] == key) {
flag = false;
break;
}
}
return flag;
}
void main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
setlocale(LC_ALL, "Russian");
char Str[128];
char Rus[] = "àáâãäååæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
char tab[] = "?.,! ";
int k = 0;
int i;
int pos = 0;
int tmp = 0;
for (i = 0; i < 128; i++) {
Str[i] = "a";
}
printf("Ââåäèòå ñòðîêó\n");
gets(Str);
printf("Ââåäèòå öèôðó, íà êîòîðóþ ñëåäóåò ñäâèíóòü êàæäóþ áóêâó\n");
scanf_s("%d", &k);
for (i = 0; Str[i] != 0; i++) {
if (Tab(Str[i]) == true) {
if (Str[i] != '¸') {
pos = Pos(Str[i]);
if ((pos + k) > 32) {
pos = pos + k - 33;
}
else {
pos += k;
}
if (Str[i] != Rus[pos - 1]) {
Str[i] = toupper(Rus[pos]);
}
else {
Str[i] = Rus[pos];
}
}
}
}
printf("Çàøèôðîâàííàÿ ñòðîêà\n");
puts(Str);
}