Advertisement
Five_NT

p4

Dec 20th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1.  
  2. int problema4(const char *input_file_name, int N)
  3. {
  4.     char chr[] = " .,-;:'""()?!", ss[2000]="";
  5.     ifstream fin(input_file_name);
  6.     while(fin.get(s, 256))
  7.     {
  8.         int n = strlen(s);
  9.         for(int i = 0; i<(int)strlen(s); i++)
  10.         {
  11.                 while(i<n && strchr(chr, s[i]))
  12.                 {
  13.                     for(ui j = i; j<strlen(s); j++)
  14.                         s[j] = s[j+1];
  15.                     n--;
  16.                 }
  17.         }
  18.  
  19.         strcat(ss, s);
  20.         fin.get();
  21.     }
  22.  
  23.     if((int)strlen(ss) < N)
  24.         N = strlen(ss);
  25.  
  26.  
  27.     char s1[N], aux[N];
  28.     ui poz = -1;
  29.  
  30.     strncpy(aux, ss, N);
  31.     strncpy(s1, ss, N);
  32.     for(int i = 0; i<N; i++)
  33.     {
  34.         char c[1];
  35.         c[0] = s1[0];
  36.         for(int j = 0; j<N-1; j++)
  37.             s1[j] = s1[j+1];
  38.         s1[N-1] = c[0];
  39.         //cout << s1 << endl;
  40.         if(strcmp(aux, s1) > 0)
  41.         {
  42.             strncpy(aux, s1, N);
  43.             poz = i + 1;
  44.         }
  45.     }
  46.     return poz;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement