Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main() {
- char str[10000] = "", line[1000];
- // Read input until a blank line
- while (fgets(line, sizeof(line), stdin)) {
- if (strcmp(line, "\n") == 0) break;
- strcat(str, line);
- }
- // Remove all newline characters
- for (char *p = str; *p; p++) {
- if (*p == '\n') *p = ' ';
- }
- char *start = str, *stop = str;
- int maxLen = 0;
- for (char *i = str; *i; i++) {
- int seen[256] = {0};
- int len = 0;
- char *j = i;
- while (*j) {
- if (*j != ' ' && seen[(unsigned char)*j]) break;
- if (*j != ' ') {
- seen[(unsigned char)*j] = 1;
- len++;
- }
- j++;
- }
- if (len >= maxLen) {
- maxLen = len;
- start = i;
- stop = j;
- }
- }
- // Print result in one line
- for (char *p = start; p < stop; p++) {
- putchar(*p);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment