Advertisement
mbah_bejo

PW-1

Nov 29th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int fbi(int satu, int dua)
  4. {
  5.     if(dua==0) return satu;
  6.     else
  7.     return fbi(dua,satu % dua);
  8. }
  9.  
  10. int  tanda[27];
  11.     int tot[101];
  12.  
  13. int main()
  14. {
  15.     int dwi,i,joko,joko1,beda1=0,beda2=0;
  16.     char nopal[101];
  17.     scanf("%d",&dwi);
  18.     for(i=0;i<dwi;i++)
  19.     {
  20.     scanf("%s",nopal);
  21.        
  22.         for(joko=0;joko<strlen(nopal);joko++)
  23.             {
  24.                     if(tanda[nopal[joko]-97]==0)
  25.                     {tanda[nopal[joko]-97]=69;
  26.                         tot[i]+=1   ;
  27.                 }
  28.                
  29.             }
  30.      memset(tanda,0,sizeof(nopal));
  31.     //  printf("%d\n",tot[i]);
  32.         if((i+1)%3==0){
  33.             if(fbi(tot[i-1],tot[i-2])%3==0)
  34.             printf("Congratulation, the gate is opened, but you must continue to try other combination.\n");
  35.             else
  36.             printf("Please try again.\n");
  37.             continue;
  38.         } else if(tot[i]%2==1){
  39.                 printf("The puzzle is still unsolved.\n");
  40.                 }
  41.              else  printf("Somehow the puzzle is solved.\n");
  42.                    
  43.     //memset(tot,0,sizeof(nopal));
  44. }
  45.     return 0;
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement