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
can you give me the makefile and fix any errors in my code.
 #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!