Advertisement
RiQ363

Untitled

Dec 28th, 2011
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.62 KB | None | 0 0
  1. // 3
  2. #include <iostream.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #define DELIMITERS " .,:;\n\t"
  9.  
  10. void funkcia1(char *s)
  11. {
  12. int i=0,f,k,j=0,l=strlen(s);
  13. char c[255],b;
  14.  
  15.  
  16. while(i<l)
  17. {
  18.     while(s[i]==' ')
  19.          i++;
  20.  
  21.     f=0;
  22.     k=i;
  23.     while((s[i]!=' ')&&(s[i]!='\0'))
  24.     {
  25.         if(s[i]==s[i+1])
  26.                   f=1;
  27.         i++;
  28.     }
  29.     if(f==1)
  30. {
  31.     while (k!=i)
  32.    {
  33.     if((s[k]>='A')&&(s[k]<='Z'))
  34.     {
  35.     c[j]=s[k];
  36.     j++;
  37.     }
  38.     k++;
  39.    }
  40. }
  41.    i++;
  42. }
  43.  
  44.  
  45. f=1;
  46. while(f!=0)
  47. {
  48.     f=0;
  49.     for(i=0;i<j-1;i++)
  50.     {
  51.         if(c[i]>c[i+1])
  52.         {
  53.         b=c[i];
  54.         c[i]=c[i+1];
  55.         c[i+1]=b;
  56.         f=1;
  57.         }
  58.     }
  59. }
  60.   printf("\n");
  61.  for(i=0;i<j;i++)
  62.   printf("%c\t",c[i]);
  63.    printf("\n");
  64. }
  65.  
  66. void funkcia2(char *s)
  67. {
  68. int i=0,f,ff,k,l=strlen(s),len=0,m=-1;
  69. char c[100],b;
  70.  
  71.  
  72. while(i<l)
  73. {
  74.     while((s[i]==' ')||(s[i]=='\0'))
  75.          i++;
  76.     f=0;
  77.     ff=0;
  78.         k=i;
  79.     i++;
  80.     while((s[i]!=' ')&&(s[i]!='\0'))
  81.     {
  82.         if((s[i]>='A')&&(s[i]<='Z'))
  83.         {
  84.             if(s[i]!=s[i-1])
  85.                          f=1;
  86.         }
  87.         else ff=1;
  88.         i++;
  89.     }
  90.     if((f==0)&&(ff==0))
  91.     {
  92.         if((i-k)>len)
  93.         {
  94.             len=i-k;
  95.             m=k;
  96.         }
  97.     }
  98.     i++;
  99. }
  100.  
  101. if(m==-1)printf("net regulyarnih cepochek");
  102. else
  103. for(i=m;i<len+m;i++)
  104. printf("%c",s[i]);  
  105. printf("\n");
  106. }
  107.  
  108.  
  109. int main()
  110. {
  111. char s[500];
  112. char *word;
  113.   printf("Str= ");
  114.    /*fgets(s,500,stdin);
  115.    word=strtok(s,DELIMITERS);
  116.    while(word!=NULL)
  117.    {
  118.     puts(word);
  119.     word=strtok(NULL,DELIMITERS);
  120.    } */
  121.  
  122. gets(s);
  123. printf("\nPostroyenie po alphavitu");
  124. funkcia1(s);
  125.  
  126. printf("Samaya dlinnaya cepochka:\n");
  127. funkcia2(s);
  128.  
  129. getch();
  130. return 0;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement