48 lines
830 B
C
48 lines
830 B
C
#include <stdio.h>
|
|
#define MAXLINE 1000
|
|
|
|
int max_len;
|
|
char current_line[MAXLINE];
|
|
char longest[MAXLINE];
|
|
|
|
int getlime();
|
|
void copy();
|
|
|
|
int main() {
|
|
int current_len;
|
|
extern int max_len;
|
|
extern char longest[];
|
|
|
|
max_len = 0;
|
|
while ((current_len = getlime()) > 0)
|
|
if (current_len > max_len) {
|
|
max_len = current_len;
|
|
copy();
|
|
}
|
|
if (max_len > 0) /* there was some line */
|
|
printf("%s", longest);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int getlime() {
|
|
int ch, i;
|
|
extern char current_line[];
|
|
|
|
for (i = 0; i < MAXLINE - 1 && (ch = getchar()) != EOF && ch != '\n'; ++i)
|
|
current_line[i] = ch;
|
|
if (ch == '\n') {
|
|
current_line[i] = ch;
|
|
++i;
|
|
}
|
|
current_line[i] = '\0';
|
|
return i;
|
|
}
|
|
|
|
void copy() {
|
|
extern char current_line[], longest[];
|
|
|
|
for (int i = 0; (longest[i] = current_line[i]) != '\0'; ++i)
|
|
;
|
|
}
|