69,370
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_COLS 128
int
main ( void )
{
char now_input [MAX_COLS];
char next_input [MAX_COLS];
char output [MAX_COLS];
gets ( now_input ); /* 这个函数的意义更大的再与输入,而不在他返回的指针 */
while ( gets ( next_input ) != NULL );{
/*
** 相同则拷贝到output 中 输出。
*/
if ( !(strcmp ( now_input , next_input )) ){
strcpy ( output , now_input );
puts ( output );
}
strcpy ( now_input , next_input );
}
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_COLS 128
int
main ( void )
{
char now_input [MAX_COLS];
char next_input [MAX_COLS];
char output [MAX_COLS];
bool already=false;//加了一个already标志位
gets ( now_input );
while ( gets ( next_input ) != NULL )
{
if ( (strcmp ( now_input , next_input )==0) )
{
if (already==false)
{
strcpy (output , now_input );
puts ( output );
already=true;
}
}
else
{
strcpy (now_input , next_input );
already=false;
}
}
return EXIT_SUCCESS;
}
#include <stdio.h>
int
main( void )
{
double nc;
for ( nc=0; getchar() !=EOF; ++nc)
;
printf("%.0f \n",nc);
}
怎样输入才能得到eof?