Mitko_jos

Davor_EBA4oc

Dec 11th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. 1va
  2. #include <stdio.h>
  3. #include <string.h>
  4. #define MAX 100
  5.  
  6. int compare(char* str1, char* str2)
  7. {
  8. int i, brojac = 0;
  9. for(i = 0; i < strlen(str1); i++) {
  10. if(*(str1 + i) == *(str2 + i)) {
  11. *(str1 + i) = *(str2 + i) = '*';
  12. brojac++;
  13. }
  14. }
  15. return brojac;
  16. }
  17.  
  18.  
  19. int main() {
  20. char firstStr[MAX], secondStr[MAX];
  21. gets(firstStr);
  22. gets(secondStr);
  23. printf("%d\n", compare (firstStr, secondStr));
  24. puts(firstStr);
  25. puts(secondStr);
  26. return 0;
  27. }
  28.  
  29. 2ra
  30. #include <stdio.h>
  31. #include <string.h>
  32. #define MAX 1000
  33.  
  34. int istaBukva(char *str) {
  35. char temp;
  36. int i,br=0;
  37. temp=str[0];
  38. for(i=0; i<strlen(str); i++) {
  39. if(str[i]==' ') {
  40. if(temp==str[i-1]) {
  41. br++;
  42. }
  43. temp=str[i+1];
  44. } else if(i==strlen(str)-1) {
  45. if(temp==str[i]) {
  46. br++;
  47. }
  48. }
  49. }
  50. return br;
  51. }
  52.  
  53. int main() {
  54. char word[MAX];
  55. gets(word);
  56. printf("%d", istaBukva(word));
  57. return 0;
  58. }
  59.  
  60. 5ta
  61. #include <stdio.h>
  62. #include <string.h>
  63. #define MAX 100
  64.  
  65. int deleteAll(char* str1, char* str2)
  66. {
  67. int ctr,ctr2;
  68. int flag=0;
  69. int broj=0;
  70. for (ctr=0; str1[ctr]!=0; ctr++)
  71. {
  72. if (str1[ctr]==str2[0])
  73. {
  74. flag=1;
  75. for (ctr2=0; str2[ctr2]!=0; ctr2++)
  76. {
  77. if (str1[ctr+ctr2]!=str2[ctr2])
  78. {
  79. flag=0;
  80. break;
  81. }
  82. }
  83. }
  84. if (flag==1)
  85. {
  86. flag=0;
  87. broj++;
  88. int x;
  89. x=ctr2;
  90. for (ctr2=0; str1[ctr2]!=0; ctr2++)
  91. {
  92. str1[ctr+ctr2]=str1[ctr+ctr2+x];
  93. }
  94. }
  95. }
  96. return broj;
  97. }
  98.  
  99.  
  100. int main() {
  101. char firstStr[MAX], secondStr[MAX];
  102. int count;
  103. gets(firstStr);
  104. gets(secondStr);
  105. count = deleteAll(firstStr, secondStr);
  106. puts(firstStr);
  107. printf("%d\n", count);
  108. return 0;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment