369 games

Asked 2 years ago, Updated 2 years ago, 72 views

When the question is 369, "Jjak" comes out and 33 comes out twice, but if the output value is 23 now, it comes out once, so please let me know what the problem is and help me fix it.

c for

2022-09-20 22:26

1 Answers

#include <stdio.h>
int main(){
    int a = 1;
    for(a; a <= 100; a++){
        if(a % 10 == 3 || a % 10 == 6 || a % 10 == 9){
            printf ("pair\n");
        }
        else if(a / 10 == 3 || a / 10 == 6 || a / 10 == 9){
            printf ("pair\n");
        }
        else{
            printf("%d\n", a);
        }
    }
    return 0;   
}

Else is missing in front of if

I've improved the code a little bit.

#include <stdio.h>
int main(){
    int a = 1;
    for(a; a <= 100; a++){
        if(a == 33 || a == 66 || a == 99){
            printf ("clap\n");
        }
        else if(a % 10 == 3 || a % 10 == 6 || a % 10 == 9){
            printf ("pair\n");
        }
        else if(a / 10 == 3 || a / 10 == 6 || a / 10 == 9){
            printf ("pair\n");
        }
        else if(a % 3 == 0){
            printf ("pair\n");
        }
        else{
            printf("%d\n", a);
        }
    }
    return 0;   
}


2022-09-20 22:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.