Time Limit:1000MS  Memory Limit:65536K
Total Submit:374 Accepted:183

Description

Input

Output

1 #include <cstdlib>
2
#include <iostream>
3
4 using namespace std;
5
6 int main(int argc, char *argv[])
7 {
8     int i,j,k,n,a[9],num;
9     for(i=123;i<=327;i++)//因为987/3=329 984/3=328 981/3=327,所以i的最小值是123，最大值是327
10     {   n=0;
11         if(i/100!=i%100/10&&i/100!=i%10&&i%100/10!=i%10&&i%100/10!=0&&i%10!=0)
12         {
13             for(j=1;j<=3;j++)//将9个数字3个为一组存入数组a[9]
14             {
15                 a[n++]=j*i/100;
16                 a[n++]=j*i%100/10;
17                 a[n++]=j*i%10;
18             }
19
20             for(j=0;j<9;j++)//去掉a[i]的值含有0元素和重复元素的项。当num==0时，输出数组a[]
21             {
22                 num=0;
23                 if(a[j]!=0)
24                   {
25                       for(k=j+1;k<9;k++)
26                     {
27                         if(a[j]==a[k])
28                         {
29                             num++;
30                           break;
31                         }
32
33                     }
34                     if(num>0)
35                         break;
36                   }
37                   else
38                   {
39                       num++;
40                       break;
41                   }
42             }
43
44             if(num==0)//输出数组a[]的所有9个元素，每三个元素为一组，后面用空格隔开
45               {
46                 for(j=1;j<10;j++)
47                 {
48                     cout<<a[j-1];
49                     if(j%3==0)
50                     cout<<" ";
51                 }
52                 cout<<endl;
53               }
54         }
55
56     }
57     system("PAUSE");
58     return 0;
59 }
60

posted on 2011-10-28 00:39 刘聪 阅读(430) 评论(0)  编辑 收藏 引用

 < 2011年10月 >
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

•