jim95022

laba ot urcaa

Dec 20th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main(void)
  5. {
  6.     char c, a1[10], a2[10];
  7.     int a[10],s,b[10], i=0, k, f,min,m=0;
  8.     FILE *aa, *bb;
  9.     printf("file vvoda\n");
  10.     scanf("%s", &a1);
  11.     printf("file vivoda\n");
  12.     scanf("%s", &a2);
  13.  
  14.     aa = fopen(a1, "r");
  15.     while ((c = fgetc(aa)) != EOF)
  16.     {
  17.         if (c != '\n')
  18.         {
  19.             s++;
  20.             a[i] = s;
  21.         }
  22.         else
  23.         {
  24.             s = 0;
  25.             i++;
  26.         }
  27.     }
  28.     fclose(aa);
  29.  
  30.     min = a[i];
  31.     f = i;
  32.     for (i = 0; f > i; i++)
  33.     {
  34.         if (a[i] < min)
  35.         {
  36.             min = a[i];
  37.             k = i;
  38.         }
  39.     }
  40.     aa = fopen(a1, "r");
  41.     bb = fopen(a2, "w");
  42.  
  43.     while ((c = fgetc(aa)) != EOF)
  44.     {
  45.         if (m == k)
  46.         {
  47.             while ((c = fgetc(aa)) != EOF || '\n')
  48.             {
  49.                 fputc(c, bb);
  50.             }
  51.         }
  52.         else
  53.         {
  54.             if (c == '\n')
  55.             {
  56.                 m++;
  57.             }
  58.         }
  59.     }
  60.     fclose(aa);
  61.     fclose(bb);
  62. }
Advertisement
Add Comment
Please, Sign In to add comment