-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstring.cpp
50 lines (49 loc) · 943 Bytes
/
string.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int t, k, n, att, rem, i, num;
long int v;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
scanf("%d",&k);
scanf("%ld",&v);
string str_arr[n];
for( i = 0; i < n; i++;)
{
getline (cin, str_arr[i]);
}
num = (v-1)*k;
rem = num%n;
att = k - rem;
if(att >= k)
{
string fin = "Case #" + to_string(t) + " " ;
for(i=0; i< k; i++;)
{
fin = fin + str_arr[i+rem];
}
fin = fin + "\0";
printf("%s",fin);
}
else
{
int kk = k - att;
string fin = "Case #" + to_string(t) + " ";
for(i=0 ; i < kk ; i++;)
{
fin = fin + str_arr[i];
}
for( ; i < k ; i++;)
{
fin = fin + str_arr[i+rem];
}
fin = fin + "\0";
printf("%s",fin);
}
}
return 0;
}