本帖最后由 丁强强 于 2013-2-3 15:07 编辑
- //代码①引用@薛虎
- class Temp
- {
- public static void main(String[] args)
- {
- int cup;
- for(int a=1; a<=30; a++)
- {
- for(int b=1; b<=30; b++)
- {
- for(int c=1; c<=30; c++)
- {
- for(int d=1; d<=30; d++)
- {
- if(a*a*a+b*b*b==c*c*c+d*d*d&&a!=b&&b!=c&&c!=d&&d!=a&&a!=c&&b!=d)
- {
- if(a<b) {cup = a; a = b; b = cup;}
- if(a<c) {cup = a; a = c; c = cup;}
- if(a<d) {cup = a; a = d; d = cup;}
- if(b<c) {cup = b; b = c; c = cup;}
- if(b<d) {cup = b; b = d; d = cup;}
- if(c<d) {cup = c; c = d; d = cup;}
- System.out.println(d+","+c+","+b+","+a);
- }
- }
- }
- }
- }
- }
- }
- [code]//代码②
- class xiangmu
- {
- public static void main(String[] args)
- {
- chazhao q = new chazhao();
- q.chazhao();
- }
- }
- class chazhao
- {
- public void chazhao()
- {
- for (int a=1;0<a && a<=30 ;a++ )
- {
- for (int b=1;0<b && b<=30 ;b++ )
- {
- for (int c=1;0<c && c<=30 ;c++ )
- {
- for (int d=1;0<d && d<=30 ;d++ )
- {
- paixu(a,b,c,d);
- }
- }
- }
- }
- }
-
- public void paixu(int a, int b, int c ,int d)
-
- {
- if(a*a*a+b*b*b==c*c*c+d*d*d&&a!=b&&b!=c&&c!=d&&d!=a&&a!=c&&b!=d)
- {
- int cup;
- if(a<b) {cup = a; a = b; b = cup;}
- if(a<c) {cup = a; a = c; c = cup;}
- if(a<d) {cup = a; a = d; d = cup;}
- if(b<c) {cup = b; b = c; c = cup;}
- if(b<d) {cup = b; b = d; d = cup;}
- if(c<d) {cup = c; c = d; d = cup;}
-
- System.out.println(a+","+b+","+c+","+d);
- }
- }
- }
复制代码 [/code] |