-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
83 lines (77 loc) · 2.04 KB
/
main.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
76
77
78
79
80
81
82
83
#include <stdio.h>
#include <stdbool.h>
#include <locale.h>
#include "Header.h"
void menu(int task_count)
{
int i = 1;
while (i <= task_count)
{
printf("%d. Çàäàíèå %d\n", i, i);
++i;
}
printf("%d. Âûõîä \n", i);
}
void main(void)
{
setlocale(LC_ALL, "Rus");
_Bool close_flag = true;
while (close_flag)
{
char str1[] = "Hello world!";
char substr[] = "lo";
char str3[] = "one";
unsigned int len1 = 0, destlen = 0, index = 0;
_Bool err;
char* point, dest[100];
printf("1. Çàäàíèå 1\n");
printf("2. Çàäàíèå 2\n");
printf("3. Çàäàíèå 3\n");
printf("4. Çàäàíèå 4\n");
printf("5. Çàäàíèå 5\n");
printf("6. Çàäàíèå 6\n");
printf("7. Âûõîä\n");
switch (getch())
{
case '1':
system("cls");
len1 = strlen(str1);
printf("Ñòðîêà - %s. Äëèíà ñòðîêè - %d \n", str1, len1);
break;
case '2':
system("cls");
point = find(str1, substr);
point == 0 ? printf("Ñòðîêà - %s. Ïîäñòðîêà - %s. \nÏîäñòðîêà íå âõîäèò â ñòðîêó \n", str1, substr) : printf("Ñòðîêà - %s. Ïîäñòðîêà - %s. \nÀäðåñ âõîæäåíèÿ - %p \n", str1, substr, point);
break;
case '3':
system("cls");
printf("Ñòðîêà - %s. Ïîäñòðîêà - %s \n", str1, substr);
delete(str1, substr);
printf("Ñòðîêà ïîñëå óäàëåíèÿ ïîäñòðîêè - %s \n", str1);
break;
case '4':
system("cls");
destlen = strlen(dest);
strcpy(dest, destlen, str1);
printf("Ñòðîêà - %s. Ïîñëå êîïèðîâàíèÿ - %s \n", str1, dest);
break;
case '5':
system("cls");
destlen = strlen(dest);
strcat(dest, destlen, str1, str3);
printf("Ñòðîêà - %s. Âòîðàÿ ñòðîêà - %s. \nÐåçóëüòàò êîíêàòåíàöèè - %s \n", str1, str3, dest);
break;
case '6':
system("cls");
destlen = strlen(dest);
printf("Ââåäèòå èíäåêñ äëÿ âñòàâêè ");
scanf_s("%d", &index);
err = insert(str1, str3, index, dest, destlen);
err ? printf("Ñòðîêà - %s. Âòîðàÿ ñòðîêà - %s. \nÐåçóëüòàò âñòàâêè - %s \n", str1, str3, dest) : printf("Îøèáêà \n");
break;
case '7':
close_flag = false;
break;
}
}
}