Advertisement
Lisaveta777

deal later

Aug 11th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <stdio.h>  //looking for the longest line, not sure where this come from, and how it's working
  2.  
  3. #define MAXLINE 1000
  4.  
  5. int get_line(int [],int);
  6. void copy(int [],int []);
  7.  
  8. int main()
  9. {
  10.     char ar[MAXLINE],max_ar[MAXLINE]= "odin dva tri";
  11.     int c,result, max = 0;
  12.  
  13.     while((result = get_line(ar,MAXLINE))!=EOF)
  14.     {
  15.         if(result>max)
  16.             {
  17.                 max = result;
  18.                 copy(max_ar,ar);
  19.             }
  20.  
  21.     }
  22.  
  23.     printf("max is %d\n",max);
  24.     return 0;
  25. }
  26. void copy(int from[],int to[])
  27. {
  28.     int i = 0;
  29.     while( (to[i]=from[i]) !='\0')
  30.            i++;
  31.  
  32. }
  33. int get_line(int arr[],int s)
  34. {
  35.     int i,c;
  36.     for(i=0;i<s && (c=getchar())!=EOF&&(c!='\n');i++)
  37.     {
  38.         arr[i] = c;
  39.     }
  40.  
  41.  
  42.     return i;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement