From 57d767cf4e4d5b83645bda2c4e398fdd76d059e1 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Mon, 2 Jan 2017 20:37:59 +0700 Subject: Update others/easy20160714 --- others/easy20160714/16.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 others/easy20160714/16.c (limited to 'others/easy20160714/16.c') diff --git a/others/easy20160714/16.c b/others/easy20160714/16.c new file mode 100644 index 0000000..33334cd --- /dev/null +++ b/others/easy20160714/16.c @@ -0,0 +1,28 @@ +#define _GNU_SOURCE +#include +#include + +int main() +{ + FILE *fi = fopen("INP.TXT", "r"), *fo = fopen("OUT.TXT", "w"); + unsigned char n, i, j, s[256], sx[256], x, y; + + fscanf(fi, "%s %hhd\n", s, &n); + + for (i = 0; i < n; i++) + if (fgetc(fi) ^ 49) { + fscanf(fi, " %hhd %hhd\n", &x, &y); + x--; + memmove(s + x, s + x + y, strlen(s) - x - y + 1); + fprintf(fo, "%s\n", s); + } else { + fscanf(fi, " %s %hhd\n", sx, &y); + strcpy(sx + strlen(sx), s + y); + strcpy(s + y, sx); + fprintf(fo, "%s\n", s); + } + + fcloseall(); + + return 0; +} -- cgit 1.4.1