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

A Fibonacci string is defined as follows: s1 = b s2 = a sk = sk1sk2 Write a C/C+

ID: 3663468 • Letter: A

Question

A Fibonacci string is defined as follows: s1 = b s2 = a sk = sk1sk2

Write a C/C++ program that recognizes strings of the form . s6. . These strings are of the form of zero or more characters followed by s6 followed by zero or more characters. The string will be passed into your program using command line arguments. Do not prompt the user for the input string. The input string will be a maximum of 80 characters. Your program will only output the strings either STRING ACCEPTED or STRING NOT ACCEPTED (nothing more, nothing less). You may not use the the string.h function strstr(). Your program must use recursion to recognize the string. Name this program csf hw1 q3.c. Include sample output in your solution.  A Fibonacci string is defined as follows: s1 = b s2 = a sk = sk1sk2 Write a C/C++ program that recognizes strings of the form . s6. . These strings are of the form of zero or more characters followed by s6 followed by zero or more characters. The string will be passed into your program using command line arguments. Do not prompt the user for the input string. The input string will be a maximum of 80 characters. Your program will only output the strings either STRING ACCEPTED or STRING NOT ACCEPTED (nothing more, nothing less). You may not use the the string.h function strstr(). Your program must use recursion to recognize the string. Name this program csf hw1 q3.c. Include sample output in your solution.

Explanation / Answer

#include <bits/stdc++.h>
using namespace std;

string fib(int n){
   if (n == 1)
       return "a";
   if (n == 2)
       return "b";
   return fib(n-1)+fib(n-2);
}


int main(int argc, char *argv[]){
   string s = argv[1];
   string f = fib(6);
   if (s1.find(f) != std::string::npos)
       cout << "STRING ACCEPTED" << endl;
   else
       cout << "STRING NOT ACCEPTED" << endl;
   return 0;
}

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