![:(](./images/smilies/icon_frown.gif)
cut...
Moderator: Board moderators
Code: Select all
1 abcde
Code: Select all
edcba
Code: Select all
1 ABCDEFGHIJKLMNOPQRSTUVWX
2 ABCDEFGHIJKLMNOPQRSTUVWX
3 ABCDEFGHIJKLMNOPQRSTUVWX
4 ABCDEFGHIJKLMNOPQRSTUVWX
6 ABCDEFGHIJKLMNOPQRSTUVWX
8 ABCDEFGHIJKLMNOPQRSTUVWX
0
Code: Select all
XWVUTSRQPONMLKJIHGFEDCBA
LKJIHGFEDCBAXWVUTSRQPONM
HGFEDCBAPONMLKJIXWVUTSRQ
FEDCBALKJIHGRQPONMXWVUTS
DCBAHGFELKJIPONMTSRQXWVU
CBAFEDIHGLKJONMRQPUTSXWV
Code: Select all
1 S
Code: Select all
int main()
{
unsigned char nbrGroups=48, lines=0, offset = 0x00, out_offset=0,
outstr[100], chars, count, groupSize, i;
string str;
//number of groups valid between 0 and 9
while((nbrGroups >= 48) && (nbrGroups <= 57) && (++lines < 11))
{
cin >> nbrGroups;
cin >> str;
offset=0;
out_offset=0;
if(nbrGroups != 48)
{
//calculate the group size
for(count=0;str[count] != 0x00; count++);
//check if the total length is multiple of nbrGroups
if(count%(nbrGroups-48) == 0)
{
groupSize = count/(nbrGroups-48);
//go throught the groups
for(count=0;count<(nbrGroups-48);count++)
{
//invert the group
for(i=offset+groupSize;i != offset ;i--)
outstr[out_offset++] = str[i-1];
//set the position to the next group
offset+=(groupSize);
}
outstr[out_offset] = 0x00;
cout << outstr << endl;
}
}
}
return 0;
}
Code: Select all
Remove after AC