我是個對電腦科學有興趣的學生,我會貼上我的學習歷程及生活心情,也請大大們多多指教。 :)

2015年7月9日 星期四

[UVa] 10361 - Automatic Poetry

題意:
(from luckycat)


解法:
字串。

注意:

程式碼:
/**
* Tittle: 10361 - Automatic Poetry
* Author: Cheng-Shih, Wong
* Date: 2015/07/09
*/
// include files
#include <bits/stdc++.h>
using namespace std;
// definitions
#define FOR(i,a,b) for( int i=(a),_n=(b); i<=_n; ++i )
#define clr(x,v) memset( x, v, sizeof(x) )
#define N 205
// declarations
int n;
char s[6][N];
char buf[N];
// functions
// main function
int main( void )
{
char *cptr;
int cnt;
// input
scanf( "%d", &n );
gets(buf);
while( n-- ) {
clr( s, 0 );
gets(buf);
cnt = 1;
cptr = s[1];
FOR( i, 0, strlen(buf)-1 ) {
if( buf[i]=='<' || buf[i]=='>' )
cptr = s[++cnt];
else
*(cptr++) = buf[i];
}
gets(buf);
sscanf( buf, "%[^.]", s[0] );
// output
FOR( i, 1, 5 ) printf( "%s", s[i] );
putchar('\n');
printf( "%s%s%s%s%s\n",
s[0], s[4], s[3], s[2], s[5] );
}
return 0;
}

沒有留言:

張貼留言

任何意見都樂意傾聽