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
i need the make file of the code. and any erros fixed.Programming Assignment
Knight Foundation School of Computing and Information Sciences
In this assignment, you are asked to implement a program that recognizes interesting
patterns for any given string. In an infinite loop, the program receives a single line from
standard input you may use fgetsline stdin to receive such line where line is a char
array of length The program must be interested in finding one or more of the following
special patterns in the input string:
I. Singleton: A singleton string is made of only one letter. Examples: mmmmm qqqqqqq
rr s yyy
II Arithmetic: A string made of subsequent alphabetical letters that appear in the alpha
betical order. Examples: bcdef, pqrstuvwx, jk y
III. Reverse Arithmetic: A string made of subsequent alphabetical letters that appear
in the reverse alphabetical order. Example: fedcb, xwvutsrqp, kj y
IV Balanced Tripartite: A string made of three identical parts. Example: busbusbus,
laptoplaptoplaptop, zzz
V Balanced Bipartite: A string made of two identical halves. Examples: ticktick,
hophop, tantan nocknock, nn
VI Palindrome: A palindrome reads the same backward as forward. Examples: abcba,
bob,
Please note that the above list is ranked in the decreasing order of their rarity. You
program prints out the list of all patterns that can be found for each input string followed
by a new line. Then, it asks for another line from input stream in a repetitive fashion. If no
pattern is found for an input string, the program prints a new line only.
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