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 | #include<stdio.h> #include<string.h> char str[20000]; int extract(int a) { int len=0; while(str[a]!=' ') len++; return len; } main() { int t; scanf("%d",&t); while(t--) { scanf("%s",str); i=0; max=0,count=1; len=extract(i); while((i+20)<=strlen(str)) { i=len+1; if(len==extract(i)) { count++; } else { len=extract(i); } if(count>max) max=count; } printf("%d\n",max); } return 0; } |
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RyaW5nLmg+CmNoYXIgc3RyWzIwMDAwXTsKaW50IGV4dHJhY3QoaW50IGEpCnsKIGludCBsZW49MDsKIHdoaWxlKHN0clthXSE9JyAnKSBsZW4rKzsKIHJldHVybiBsZW47Cn0KCm1haW4oKQp7CiBpbnQgdDsKIHNjYW5mKCIlZCIsJnQpOwogd2hpbGUodC0tKQp7CiBzY2FuZigiJXMiLHN0cik7CiBpPTA7CiBtYXg9MCxjb3VudD0xOwogbGVuPWV4dHJhY3QoaSk7CiB3aGlsZSgoaSsyMCk8PXN0cmxlbihzdHIpKQogewogaT1sZW4rMTsKICBpZihsZW49PWV4dHJhY3QoaSkpIHsgIGNvdW50Kys7IH0KICBlbHNlIHsgbGVuPWV4dHJhY3QoaSk7IH0KICBpZihjb3VudD5tYXgpIG1heD1jb3VudDsKIH0KcHJpbnRmKCIlZFxuIixtYXgpOwp9CnJldHVybiAwOwp9
prog.c:12: warning: return type defaults to ‘int’ prog.c: In function ‘main’: prog.c:18: error: ‘i’ undeclared (first use in this function) prog.c:18: error: (Each undeclared identifier is reported only once prog.c:18: error: for each function it appears in.) prog.c:19: error: ‘max’ undeclared (first use in this function) prog.c:19: error: ‘count’ undeclared (first use in this function) prog.c:19: warning: left-hand operand of comma expression has no effect prog.c:20: error: ‘len’ undeclared (first use in this function) prog.c:14: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result prog.c:17: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
-
result: Compilation error (maybe you wish to see an example for C)
2 a aa bb cc def ghi a a a a a bb bb bb bb c c



