Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int checkArray(int a[],int length);
- int main(void) {
- int array[9] = {1,2,2,1,2,3,3,2,1};
- if(checkArray(array,9) == 1){
- printf("Stimmt!");
- }else{
- printf("Stimmt nicht!");
- }
- return EXIT_SUCCESS;
- }
- int checkArray(int a[],int length){
- int durchlaeufe = length/3;
- int index = 1;
- for (int i=0;i<durchlaeufe;i++){
- if(a[index] == a[index-1] || a[index] == a[index+1]){
- return 0;
- }
- if(a[index-1] == a[index+1]){
- return 0;
- }
- index = index+3;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement