//从标准输入输入几行,并计算出它们的长度(包括\n),打印出最长的一行及其长度

#include<stdio.h>

#include<process.h>

int main()

{

int ch = 0;

int i = 0;

int j = 0;

int k = 0;

int arr[1000] = { 0 };

int arr0[1000] = {0};

int count = 0;

int max_count = 0;

while ((ch = getchar()) != EOF)

{

count++;

        arr[i] =ch;

i++;

        if ((count>max_count)&&(ch == '\n'))

{

for (k = 0; k < i; k++)

{

arr0[k] = arr[k];

}

max_count = count;

count = 0;

i = 0;

}

else if (ch == '\n')

{

count = 0;

i = 0;

}

}

for (j = 0; j < max_count; j++)

{

printf("%c ", arr0[j]);

}

printf("%d\n", max_count);

system("pause");

return 0;

}

j_0048.gif