Jump to content
Fórum Script Brasil
  • 0

Problema com lógica de programação


Question

#include <stdio.h>
#include <string.h>
#define SIZE 100
int main (void) {
	char str1[SIZE],str2[SIZE];
	int tamanhop,tamanho2,i,j;
	char res[SIZE];
	int count=0;
	fgets(str1,SIZE,stdin);
	fgets(str2,SIZE,stdin);
	tamanhop = strlen(str1);
	while(tamanhop>0){
		for(j=0;(str1[j]!='\0')&&(str1[j]!=' ');j++){
			if(str1[j]==str2[j]){
				res[j] = str2[j];
			}
		} 
	}
	printf("String menor aparece %d vezes\n", count);
}

Dado o seguinte código, eis o problema: 
O programa lerá duas strings. A primeira será uma frase e a segunda uma palavra que se repetirá na primeira string. O exercício pede que eu conte quantas vezes essa palavra (string2) aparecerá na string1. 

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing


  • Forum Statistics

    • Total Topics
      148978
    • Total Posts
      645025
×
×
  • Create New...