Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This problem is about c code for Microsoft visual studio. It can be found by fol

ID: 647751 • Letter: T

Question

This problem is about c code for Microsoft visual studio. It can be found by following two links(indluding two images):

https://drive.google.com/file/d/0B7WUYmW3LyL6cEJSWHFuOHFqdVE/view?usp=sharing

https://drive.google.com/file/d/0B7WUYmW3LyL6N0FXQmx1WXUtOFk/view?usp=sharing

Now I nearly finish it. The sample 1 and 2 works correctly, but the sample 3(including ',' ) and sample 4(pure digits array) still doesn't work well. Please revise the program to make sure sample 3 and 4 are working.

Here is my currectly using code:


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define len 100


int FindStringSegment(char str[], char str1[], int s){
   int i, j;
  
   for (i = s; i <= strlen(str) - strlen(str1); ++i){
       int flag = 0;
       for (j = i; j < (i + strlen(str1)); ++j){
          
           if (str[j] != str1[j - i]){
               flag = 1;
              
           }
          
       }
       if (flag == 0){
           return i;
       }
   }
   return -1;
}

int main(void) {
   int size = len;
   char ch;
   int count1 = 0, count2 = 0;
   int n=0;
   char str[len];
   char str1[len];
   printf("Input a string to find with the test string: ");
   do{
       scanf_s("%c", &ch, 1);
       if (ch == ' '){
           str[count1] = '';
           break;
       }
       else{
           str[count1++] = ch;
       }
   } while (1);
   printf("Input a string to find within the test string: ");
   do{
       scanf_s("%c", &ch, 1);
       if (ch == ' '){
           str1[count2] = '';
           break;
       }
       else{
           str1[count2++] = ch;
       }
   } while (1);
   printf("The test string is: %s ", str);
   int s = 0;
   while (1){
       int ind = FindStringSegment(str, str1, s);
       n++;
       if (ind == -1){
           break;
       }
       else{
           printf("%s found at column %d ", str1, ind);
           s = ind + 1;
          
       }
   }
   printf("%s was found a total of %d times. ", str1, n-1);
   return(0);
}

Explanation / Answer

This is answer:

Here We can use Generic Functions for the Sample4:

mainly some Url contains digits .in that manner we may use follwing code it can use for work.

#include<iostream>

#include<ctyee.in>

#include<string>

#include<stdio.h>

int main()

{

int i,count=0;

int len;

char str[len],str1[len];

printf("Enter string");

int cusymb(str);

int c=cusymb(str);

if(c==-1)

break;

else

print("tje counc is ",count);

}

int cusymbl(char str[],char str[],int k)

{

str1=str;

for(i=1;i<1;i++)

{

if(toupper(str.at(i))=="/n"")

{

if(str.at(i-1)==' .'  && str.at(i+1)=='.')

count++;

if(toupper(str.at(0))=="A" && str.at(1)=='.")

count++;

if(toupper(str.at(len-1))=='A' && str.at(l-2)=='.")

count++;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote