C语言趣味程序百例精解之java实现(17)平分七筐鱼

程序:
- public class Test17{
- public static void main(String args[]){
- for(int a=1;a<=7;a++)
- for(int b=1;b<=7;b++)
- for(int c=1;c<=7;c++)
- for(int x=1;x<=7;x++)
- for(int y=1;y<=7;y++)
- for(int z=1;z<=7;z++)
- for(int m=1;m<=7;m++)
- for(int n=1;n<=7;n++)
- for(int l=1;l<=7;l++){
- if((a+b+c==7)&&(x+y+z==7)&&(m+n+l==7)&&
- (a+0.5*x==3.5)&&(b+0.5*y==3.5)&&(c+0.5*z==3.5)&&
- (a+x+m==7)&&(b+y+n==7)&&(c+z+l==7)){
-
- System.out.printf("第1人分满筐,半筐,空筐分别为:(%d,%d,%d)
- ",a,x,m);
- System.out.printf("第2人分满筐,半筐,空筐分别为:(%d,%d,%d)
- ",b,y,n);
- System.out.printf("第3人分满筐,半筐,空筐分别为:(%d,%d,%d)
- ",c,z,l);
- System.out.printf("
- ");
- }
- }
- }
-
- }
- C:at>javac Test17.java
- C:at>java Test17
- 第1人分满筐,半筐,空筐分别为:(1,5,1)
- 第2人分满筐,半筐,空筐分别为:(3,1,3)
- 第3人分满筐,半筐,空筐分别为:(3,1,3)
- 第1人分满筐,半筐,空筐分别为:(2,3,2)
- 第2人分满筐,半筐,空筐分别为:(2,3,2)
- 第3人分满筐,半筐,空筐分别为:(3,1,3)
- 第1人分满筐,半筐,空筐分别为:(2,3,2)
- 第2人分满筐,半筐,空筐分别为:(3,1,3)
- 第3人分满筐,半筐,空筐分别为:(2,3,2)
- 第1人分满筐,半筐,空筐分别为:(3,1,3)
- 第2人分满筐,半筐,空筐分别为:(1,5,1)
- 第3人分满筐,半筐,空筐分别为:(3,1,3)
- 第1人分满筐,半筐,空筐分别为:(3,1,3)
- 第2人分满筐,半筐,空筐分别为:(2,3,2)
- 第3人分满筐,半筐,空筐分别为:(2,3,2)
- 第1人分满筐,半筐,空筐分别为:(3,1,3)
- 第2人分满筐,半筐,空筐分别为:(3,1,3)
- 第3人分满筐,半筐,空筐分别为:(1,5,1)
复制代码
源码下载:http://file.javaxxz.com/2014/11/24/000521062.zip |