Describe your issue
I have submitted the solution multiple times to practice array problem Check if the array is sorted Practice Problem in Arrays
It gives a compile error saying :
sol.c:40:5: error: redefinition of ‘main’
40 | int main() {
| ^~~~
sol.c:21:5: note: previous definition of ‘main’ with type ‘int()’
21 | int main() {
| ^~~~
The Solution is correct and should work
Screenshot
my solution :-
#include<stdio.h>
#include<stdbool.h>
bool check(int nums, int n) {
int count = 0;
for (int i = 0; i < n; i++) {
if (nums[i] > nums[(i + 1) % n]) {
count++;
}
}
return count <= 1;
}
int main(){
int t;
scanf(“%d”, &t);
while (t–) {
int n;
scanf(“%d”, &n);
int nums[n];
for (int i = 0; i < n; i++) {
scanf(“%d”, &nums[i]);
}
if (check(nums, n)) {
printf(“true\n”);
} else {
printf(“false\n”);
}
}
return 0;
}
