Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1va
- #include <stdio.h>
- #include <string.h>
- #define MAX 100
- int compare(char* str1, char* str2)
- {
- int i, brojac = 0;
- for(i = 0; i < strlen(str1); i++) {
- if(*(str1 + i) == *(str2 + i)) {
- *(str1 + i) = *(str2 + i) = '*';
- brojac++;
- }
- }
- return brojac;
- }
- int main() {
- char firstStr[MAX], secondStr[MAX];
- gets(firstStr);
- gets(secondStr);
- printf("%d\n", compare (firstStr, secondStr));
- puts(firstStr);
- puts(secondStr);
- return 0;
- }
- 2ra
- #include <stdio.h>
- #include <string.h>
- #define MAX 1000
- int istaBukva(char *str) {
- char temp;
- int i,br=0;
- temp=str[0];
- for(i=0; i<strlen(str); i++) {
- if(str[i]==' ') {
- if(temp==str[i-1]) {
- br++;
- }
- temp=str[i+1];
- } else if(i==strlen(str)-1) {
- if(temp==str[i]) {
- br++;
- }
- }
- }
- return br;
- }
- int main() {
- char word[MAX];
- gets(word);
- printf("%d", istaBukva(word));
- return 0;
- }
- 5ta
- #include <stdio.h>
- #include <string.h>
- #define MAX 100
- int deleteAll(char* str1, char* str2)
- {
- int ctr,ctr2;
- int flag=0;
- int broj=0;
- for (ctr=0; str1[ctr]!=0; ctr++)
- {
- if (str1[ctr]==str2[0])
- {
- flag=1;
- for (ctr2=0; str2[ctr2]!=0; ctr2++)
- {
- if (str1[ctr+ctr2]!=str2[ctr2])
- {
- flag=0;
- break;
- }
- }
- }
- if (flag==1)
- {
- flag=0;
- broj++;
- int x;
- x=ctr2;
- for (ctr2=0; str1[ctr2]!=0; ctr2++)
- {
- str1[ctr+ctr2]=str1[ctr+ctr2+x];
- }
- }
- }
- return broj;
- }
- int main() {
- char firstStr[MAX], secondStr[MAX];
- int count;
- gets(firstStr);
- gets(secondStr);
- count = deleteAll(firstStr, secondStr);
- puts(firstStr);
- printf("%d\n", count);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment