that_one_nigga_you_k

apenas 1 codigo

Nov 13th, 2023 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.81 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main() {
  5.  
  6.     int rodadas, a, b;
  7.     int vitoriasapo = 0, vitoriashuas = 0;
  8.  
  9.     scanf("%d", &rodadas);
  10.    
  11.     for (int i = 0; i < rodadas; i++) {
  12.  
  13.         scanf("%d %d", &a, &b);
  14.  
  15.         int ehPrimoA = 1, ehPrimoB = 1;
  16.  
  17.         for (int j = 2; j <= a / 2; j++) {
  18.             if (a % j == 0) {
  19.                 ehPrimoA = 0;   //n?o ? primo
  20.                 break;
  21.             }
  22.         }
  23.         if(a == 1){
  24.             ehPrimoA = 0;  //caso especial do 1
  25.         }
  26.         for (int j = 2; j <= b / 2; j++) {
  27.             if (b % j == 0) {
  28.                 ehPrimoB = 0;  //n?o ? primo
  29.                 break;
  30.             }
  31.         }
  32.         if(b == 1){
  33.             ehPrimoB = 0;  //caso especial do 1
  34.         }
  35.         // pedra vs tesoura
  36.         if ((a % 2 == 0 && a != 2) && (b%2 != 0 && (ehPrimoB == 0))) {
  37.             vitoriasapo++;
  38.         }
  39.        
  40.         else if ((a % 2 != 0 && (ehPrimoA == 0)) && ( b % 2 == 0 && b != 2)) {
  41.             vitoriashuas++;
  42.         }
  43.         // papel vs pedra
  44.          else if (( b % 2 == 0 && b != 2) && ehPrimoA) {
  45.             vitoriasapo++;
  46.         }
  47.        
  48.         else if ((a % 2 == 0 && a != 2) && ehPrimoB) {
  49.             vitoriashuas++;
  50.         }
  51.         //tesoura vs papel
  52.         else if ((a % 2 != 0 && (ehPrimoA == 0)) && ehPrimoB) {
  53.            vitoriasapo++;
  54.         }
  55.        
  56.         else if ((b%2 != 0 && (ehPrimoB == 0)) && ehPrimoA) {
  57.             vitoriashuas++;
  58.         }
  59.     }
  60.     if (vitoriasapo > vitoriashuas) {
  61.         printf("Sapo sopa esta de boa na lagoa!\n", vitoriasapo);
  62.     }
  63.    
  64.     else if (vitoriashuas > vitoriasapo) {
  65.         printf("Testemunhe a verdadeira forca!\n", vitoriashuas);
  66.     }
  67.    
  68.     else {
  69.         printf("Impending doom approaches...\n");
  70.     }
  71.     return 0;
  72. }
Add Comment
Please, Sign In to add comment