-
Notifications
You must be signed in to change notification settings - Fork 1
/
[Str]InsertStr.cpp
36 lines (36 loc) · 933 Bytes
/
[Str]InsertStr.cpp
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
/*
*File name:
*Source file name:
*Author: Tamkien Cao
*Last modified: Mon, Mar 25th, 2019
*Other info: exercise 6.11
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int k, chen;
char a[1000], chuoi[1000];
printf("Phan mem nay giup ban chen mot so ki tu tu sau vi tri ban chon.\n");
printf("Nhap mot chuoi vao day:\t");
gets_s(a);
printf("Nhap chuoi ban muon chen:\t");
gets_s(chuoi);
printf("Nhap vi tri ky tu ban muon bat dau chen:\t");
scanf_s("%d", &chen);
k = chen + strlen(chuoi);
for (int j = strlen(a) + strlen(chuoi); j >= k; j--)
{
a[j] = a[j - strlen(chuoi)];
}
for ( int i = 0; i < strlen(chuoi); i++)//vcl tu gio deo bao gio lam co nua dcm :)
{
a[i + chen] = chuoi[i];
}
printf("Chuoi moi cua ban la:\t");
printf("%s", a);
printf("\n=================================\n");
printf("Written by Tamkien Cao. Thank you for using my application!\n");
system("pause");
}