Guest User

LABA7(B)Nomer 10

a guest
Feb 24th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #define KONEC ".,:;?!\n\t"
  4. #define N 1024
  5.  
  6. int Isupper(char *s)
  7. {
  8. int i,count=0;
  9. for(i = 0 ; s[i] != '\0';i++)
  10. if(isupper(s[i]))
  11. count++;
  12. return count;
  13. }
  14. int Isdigit(char *s)
  15. {
  16. int i,count=0;
  17. for(i = 0 ; s[i] != '\0';i++)
  18. if(isdigit(s[i]))
  19. count++;
  20. return count;
  21. }
  22. int Isalpha(char *s)
  23. {
  24. int i,count=0;
  25. for(i = 0 ; s[i] != '\0';i++)
  26. if(isalpha(s[i]))
  27. count++;
  28. return count;
  29. }
  30. void Del(char *s)
  31. {
  32. int i,j;
  33. char buf;
  34. for( i = 0 ; s[i] !='\0'; i++)
  35. if(s[i]=='A' || s[i]=='E' || s[i]=='I' || s[i]=='O' || s[i]=='U')
  36. {
  37. for(j=i;s[j+1] != '\0';j++)
  38. {
  39. buf=s[j];
  40. s[j]=s[j+1];
  41. s[j+1]=buf;
  42. }
  43. s[j]='\0';
  44. }
  45. puts(s);
  46. }
  47. int main()
  48. {
  49. char s[N];
  50. char *word,*buf="\0";
  51. int i,j,flag[256]={0},k=0,max,end;
  52. fgets(s,N,stdin);
  53. for(i = 0; KONEC[i]; i++)
  54. flag[KONEC[i]]=1;
  55. for( i = 0 ; s[i] && flag[s[i]]; i++)
  56. ;
  57. while(s[i])
  58. {
  59. word = &s[i]; //s + i;
  60. while( s[i] && !flag[s[i]])
  61. i++;
  62. j = i;
  63. while( s[i] && flag[s[i]])
  64. i++;
  65. s[j] = '\0';
  66. end=strlen(word); //razmer stroki do \0
  67. if(Isdigit(word)==end) // Slovo iz cifr
  68. {
  69. printf("\nSlovo TOKO IZ CIFR\n");
  70. puts(word);
  71. }
  72.  
  73.  
  74. if(Isalpha(word)==end) //slovo iz bukv
  75. {
  76. printf("\nSLovo TOKO IZ BUKV\n");
  77. puts(word);
  78. }
  79.  
  80.  
  81.  
  82. if(Isupper(word)==end) // esli vse bukvi v stroke BIG
  83. if(end>strlen(buf))
  84. {
  85. max=end;
  86. buf=word;
  87. }
  88. }
  89. printf("\nMax Stroka=\n");
  90. puts(buf);
  91. printf("\nvizov DEL\n");
  92. Del(buf);
  93. printf("\nOTVET\n");
  94. puts(buf);
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment