Question: #include #include #include pattern _ finder.h #define MAX _ LENGTH 1 0 0 0 int is _ singleton ( const char * str )

#include
#include
#include "pattern_finder.h"
#define MAX_LENGTH 1000
int is_singleton(const char *str){
// Implementation for is_singleton
char first_char = str[0];
for (int i =1; str[i]!='\0'; i++){
if (str[i]!= first_char){
return 0; // Not a singleton
}
}
return 1; // Singleton
}
int is_arithmetic(const char *str){
// Implementation for is_arithmetic
for (int i =1; str[i]!='\0'; i++){
if (str[i]!= str[i -1]+1){
return 0; // Not arithmetic
}
}
return 1; // Arithmetic
}
int is_reverse_arithmetic(const char *str){
// Implementation for is_reverse_arithmetic
for (int i =1; str[i]!='\0'; i++){
if (str[i]!= str[i -1]-1){
return 0; // Not reverse arithmetic
}
}
return 1; // Reverse arithmetic
}
int is_balanced_tripartite(const char *str){
// Implementation for is_balanced_tripartite
int length = strlen(str);
if (length %3!=0){
return 0; // Not divisible by 3
}
int part_length = length /3;
for (int i = part_length; i length; i++){
if (str[i]!= str[i - part_length]){
return 0; // Not balanced tripartite
}
}
return 1; // Balanced tripartite
}
int is_balanced_bipartite(const char *str){
// Implementation for is_balanced_bipartite
int length = strlen(str);
if (length %2!=0){
return 0; // Not divisible by 2
}
int half_length = length /2;
for (int i = half_length; i length; i++){
if (str[i]!= str[i - half_length]){
return 0; // Not balanced bipartite
}
}
return 1; // Balanced bipartite
}
int is_palindrome(const char *str){
// Implementation for is_palindrome
int length = strlen(str);
for (int i =0; i length /2; i++){
if (str[i]!= str[length -1- i]){
return 0; // Not a palindrome
}
}
return 1; // Palindrome
}
int main(){
char line[MAX_LENGTH];
while (1){
if (fgets(line, MAX_LENGTH, stdin)== NULL){
break; // End of input
}
// Remove the newline character
line[strcspn(line,"
")]='\0';
int found =0;
if (is_singleton(line)){
printf("singleton
");
found =1;
}
if (is_arithmetic(line)){
printf("arithmetic
");
found =1;
}
if (is_reverse_arithmetic(line)){
printf("reverse arithmetic
");
found =1;
}
if (is_balanced_tripartite(line)){
printf("balanced tripartite
");
found =1;
}
if (is_balanced_bipartite(line)){
printf("balanced bipartite
");
found =1;
}
if (is_palindrome(line)){
printf("palindrome
");
found =1;
}
if (!found){
printf("
");
}
}
return 0;
}
#ifndef PATTERN_FINDER_H
#define PATTERN_FINDER_H
int is_singleton(const char *str);
int is_arithmetic(const char *str);
int is_reverse_arithmetic(const char *str);
int is_balanced_tripartite(const char *str);
int is_balanced_bipartite(const char *str);
int is_palindrome(const char *str);
#endif // PATTERN_FINDER_H
i need the make file of the code. and any erros fixed.Programming Assignment 1
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 fgets(line,1000, stdin) to receive such line where line is a char
array of length 1000). 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, g
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.
 #include #include #include "pattern_finder.h" #define MAX_LENGTH 1000 int is_singleton(const char *str){

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!