百鸡百钱问题

来源:互联网 发布:软件测试管理系统 编辑:程序博客网 时间:2024/05/22 02:13


#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;

}

0 0
原创粉丝点击