Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 3
- #include <iostream.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
- #define DELIMITERS " .,:;\n\t"
- void funkcia1(char *s)
- {
- int i=0,f,k,j=0,l=strlen(s);
- char c[255],b;
- while(i<l)
- {
- while(s[i]==' ')
- i++;
- f=0;
- k=i;
- while((s[i]!=' ')&&(s[i]!='\0'))
- {
- if(s[i]==s[i+1])
- f=1;
- i++;
- }
- if(f==1)
- {
- while (k!=i)
- {
- if((s[k]>='A')&&(s[k]<='Z'))
- {
- c[j]=s[k];
- j++;
- }
- k++;
- }
- }
- i++;
- }
- f=1;
- while(f!=0)
- {
- f=0;
- for(i=0;i<j-1;i++)
- {
- if(c[i]>c[i+1])
- {
- b=c[i];
- c[i]=c[i+1];
- c[i+1]=b;
- f=1;
- }
- }
- }
- printf("\n");
- for(i=0;i<j;i++)
- printf("%c\t",c[i]);
- printf("\n");
- }
- void funkcia2(char *s)
- {
- int i=0,f,ff,k,l=strlen(s),len=0,m=-1;
- char c[100],b;
- while(i<l)
- {
- while((s[i]==' ')||(s[i]=='\0'))
- i++;
- f=0;
- ff=0;
- k=i;
- i++;
- while((s[i]!=' ')&&(s[i]!='\0'))
- {
- if((s[i]>='A')&&(s[i]<='Z'))
- {
- if(s[i]!=s[i-1])
- f=1;
- }
- else ff=1;
- i++;
- }
- if((f==0)&&(ff==0))
- {
- if((i-k)>len)
- {
- len=i-k;
- m=k;
- }
- }
- i++;
- }
- if(m==-1)printf("net regulyarnih cepochek");
- else
- for(i=m;i<len+m;i++)
- printf("%c",s[i]);
- printf("\n");
- }
- int main()
- {
- char s[500];
- char *word;
- printf("Str= ");
- /*fgets(s,500,stdin);
- word=strtok(s,DELIMITERS);
- while(word!=NULL)
- {
- puts(word);
- word=strtok(NULL,DELIMITERS);
- } */
- gets(s);
- printf("\nPostroyenie po alphavitu");
- funkcia1(s);
- printf("Samaya dlinnaya cepochka:\n");
- funkcia2(s);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement