1
Trying to make a bingo with matrix in C, however the verification of the drawn values does not identify correctly with the matrix.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(){
    srand(time(NULL));
    int sorteio = 0;
    int p1 = 0;
    int p2 = 0; 
    int c1[4][4], c2[4][4],i, j;
    for(i = 0;i < 4; i++ ){
        for(j = 0; j < 4; j++){
            c1[i][j] = rand()%50;
            c2[i][j] = rand()%50;
        }
    }
    for(i = 0;i < 4; i++ ){
        for(j = 0; j < 4; j++){
            printf("%i ",c1[i][j]);
            }
        printf("\n");
    }
    printf("\n");
    for(i = 0;i < 4; i++ ){
        for(j = 0; j < 4; j++){
            printf("%i ",c2[i][j]);
            }
        printf("\n");
    }
    sorteio = rand() %50;
    printf ("%i ", sorteio);    
    while (p1 <= 16 || p2 <= 16){
        for(i = 0;i < 4; i++ ){
            for(j = 0; j < 4; j++){
                if (c1[i][j] == sorteio){
                    p1++;}  
                if (c2[i][j] == sorteio){
                    p2++;}
                }
            }
    sorteio = rand() %50;
    printf ("%i ", sorteio);
    if (p1 == 16){
        printf("\nBingo! Jogador 1 ganhou\n");
        return 0;}
        else{   
            if (p2 == 16){
                printf("\nBingo! Jogador 2 ganhou\n");
                return 0;}
                else{
                    printf("empate");
                    return 0;}
        }
    }
}
Note that when one of the two players reaches 16 it should no longer enter the loop.
– anonimo