Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include pattern _ finder.h #define MAX _ LENGTH 1 0 0 0 int is _ singleton ( const char * str )
#include
#include
#include "patternfinder.h
#define MAXLENGTH
int issingletonconst char str
Implementation for issingleton
char firstchar str;
for int i ; stri; i
if stri firstchar
return ; Not a singleton
return ; Singleton
int isarithmeticconst char str
Implementation for isarithmetic
for int i ; stri; i
if stri stri
return ; Not arithmetic
return ; Arithmetic
int isreversearithmeticconst char str
Implementation for isreversearithmetic
for int i ; stri; i
if stri stri
return ; Not reverse arithmetic
return ; Reverse arithmetic
int isbalancedtripartiteconst char str
Implementation for isbalancedtripartite
int length strlenstr;
if length
return ; Not divisible by
int partlength length ;
for int i partlength; i length; i
if stri stri partlength
return ; Not balanced tripartite
return ; Balanced tripartite
int isbalancedbipartiteconst char str
Implementation for isbalancedbipartite
int length strlenstr;
if length
return ; Not divisible by
int halflength length ;
for int i halflength; i length; i
if stri stri halflength
return ; Not balanced bipartite
return ; Balanced bipartite
int ispalindromeconst char str
Implementation for ispalindrome
int length strlenstr;
for int i ; i length ; i
if stri strlength i
return ; Not a palindrome
return ; Palindrome
int main
char lineMAXLENGTH;
while
if fgetsline MAXLENGTH, stdin NULL
break; End of input
Remove the newline character
linestrcspnline
;
int found ;
if issingletonline
printfsingleton
;
found ;
if isarithmeticline
printfarithmetic
;
found ;
if isreversearithmeticline
printfreverse arithmetic
;
found ;
if isbalancedtripartiteline
printfbalanced tripartite
;
found ;
if isbalancedbipartiteline
printfbalanced bipartite
;
found ;
if ispalindromeline
printfpalindrome
;
found ;
if found
printf
;
return ;
#ifndef PATTERNFINDERH
#define PATTERNFINDERH
int issingletonconst char str;
int isarithmeticconst char str;
int isreversearithmeticconst char str;
int isbalancedtripartiteconst char str;
int isbalancedbipartiteconst char str;
int ispalindromeconst char str;
#endif PATTERNFINDERH
can you give me the makefile and fix any errors in my code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started