thats my third time sending this question and no one giving me correect answer!!
ID: 3699671 • Letter: T
Question
thats my third time sending this question and no one giving me correect answer!!!!!!!!!!!!!!!!!!!
in c languge!
12.3 P3 - Ex1: Substrings Compute and output the number of ways in which we can choose two identical non-overlapping substrings of a given string read from the user Constraints Read the string from the user. The given string will consist only of lowercase English letters (a-z). The length of the given string will be between 1 and 50, inclusive. . . Output your result using the following format'%d ". Example 1 When the input is Output must be Example 2 When the input is aba Output must be Example 3 When the input is abab Output must be LAB ACTIVITY 12.3.1: P3- Ex1: Substrings 0/65Explanation / Answer
#include <stdio.h>
#include <string.h>
main()
{
char str[100];
int count = 0, len = 0, flag = 1;
printf("Enter the string : ");
scanf("%s",str);
for(;str[len]; len++);
for(int i=0; i<len; i++)
{
for(int j=i; j<len; j++)
{
for(int k=j+1; (k+j-i)<len; k++)
{
flag = 1;
for(int l=i; l<=j; l++)
{
if(str[k+l-i] != str[l])
{
flag = 0;
break;
}
}
if(flag == 1)
count++;
}
}
}
printf("%d ",count);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.