三人借書(5本)問題



#include <stdio.h>


int main()

{
   
    int a;
   
    int b;
   
    int c;
   
    int count = 0;

   
    for(a = 1; a <= 5;a++)
   
    {
       
        for(b = 1; b <= 5;b++)
 
        {
    
            for(c = 1;c <= 5;c++)
    
            {
        
                if((a != b) && (a != c) && (b != c))
  
                {
     
                    printf("a borrow %d ,b borrow %d,c borrow %d\n",a,b,c);
     
                    count++;
  
                }
    
             }
 
         }
   
     }
   
     printf("there have %d ways to do it\n",count);
   
     return 0;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章