Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这!C能过,GCC就过不了!附代码!#include<stdio.h> #include<string.h> #define N 100001 int KMP(char a[], char b[]) { int k1, k2, i; int count; k1 = strlen(a); k2 = strlen(b); count = 0; for (i=0; i<k1&&i<k2; i++) { if (a[i] == b[i]) { count++; } else { break; } } return count; } int main() { char str[N][12]; int i, k, p; int count; fscanf(stdin, "%s", str[0]); printf("%s\n", str[0]); i = 1; count = 0; while (fscanf(stdin, "%s", str[i]) != EOF) { k = KMP(str[i], str[i-1]); if (k > count) { count++; } else { count = k; } for (p=0; p<count; p++) printf(" "); printf("%s\n", str[i]); i++; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator