33,008
社区成员
发帖
与我相关
我的任务
分享
#include <cstdlib>
#include <cstdio>
using namespace std;
#define N 200
unsigned int a[N]={1};
int main(int argc, char *argv[])
{
int i1=0, i2=0, i3=0;
unsigned int r1=a[0]*3, r2=a[0]*5, r3=a[0]*7;
for(int i=1; i<N; i++){
if (r1<=r2 && r1<=r3){
a[i]=r1;
i1++;
if (r1==r2) {i2++; r2=a[i2]*5;}
if (r1==r3) {i3++; r3=a[i3]*7;}
r1=a[i1]*3;
}
else if (r2<=r1 && r2<=r3){
a[i]=r2;
i2++;
if (r2==r3) {i3++; r3=a[i3]*7;}
r2=a[i2]*5;
}
else {
a[i]=r3;
i3++;
r3=a[i3]*7;
}
}
for(int i=0; i<N; i++)
printf("%d ", a[i]);
system("PAUSE");
return EXIT_SUCCESS;
}