69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#define MAX 1000
int getline(int c[]);//get a line for cin,return the longth of the line
int copy(int s[],int t[]);//copy s[] to t[]
main(){
int max,n,i;
int longest[MAX],store[MAX];
max=0;
while((n=getline(store))!=0)
if(n>max) { //if the new line if longer
max=n; // then update max,and store the new line
copy(store,longest);
}
printf("%s\n",longest);//print the longgest one
for(i=0;longest[i]!='\0';i++) putchar(longest[i]);//the same as printf
}
int getline(int ch[MAX]){
int i,n,c;
i=0;
while(i<MAX&&(c=getchar())!=EOF&&c!='\n')
{ ch[i]=c;i++;}
if(c=='\n')
{ch[i]=c;i++;}
ch[i]='\0';
return i;
}
int copy(int s[],int t[]){
int i;
i=0;
while((t[i]=s[i])!='\0')
i++;
return 0;
}
#include <stdio.h>
#define MAX 1000
int getline(char c[]);//get a line for cin,return the longth of the line
int copy(char s[],char t[]);//copy s[] to t[]
int main()
{
int max,n,i;
char longest[MAX], store[MAX];
max=0;
while((n=getline(store))!=0)
if(n>max) { //if the new line if longer
max=n; // then update max,and store the new line
copy(store,longest);
}
printf("%s\n",longest);//print the longgest one
for(i=0;longest[i]!='\0';i++) putchar(longest[i]);//the same as printf
}
int getline(char ch[MAX])
{
int i,n,c;
i=0;
while(i<MAX&&(c=getchar())!=EOF&&c!='\n')
{
ch[i]=c;
i++;
}
if(c=='\n')
{
ch[i]=c;
i++;
}
ch[i]='\0';
return i;
}
int copy(char s[],char t[])
{
int i;
i=0;
while((t[i]=s[i])!='\0')
i++;
return 0;
}