usaco The Clocks

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wlzzhcsdn/article/details/78225605

没想到好方法,9个循环……


#include <iostream>
#include <fstream>
#include <string.h>
int ans[4][4]={0};
int a[10];
int tr[4][4]={0};
bool check();
void move(int,int);
void movehelp(int a[][4],int,int);
using namespace std;
int main()
{
 ifstream cin("clocks.in");
 ofstream cout("clocks.out");
 int i,j;
 for(i=1;i<=3;i++)
  for(j=1;j<=3;j++)
   cin>>ans[i][j];
 for(a[1]=0;a[1]<4;a[1]++)
  for(a[2]=0;a[2]<4;a[2]++)
   for(a[3]=0;a[3]<4;a[3]++)
    for(a[4]=0;a[4]<4;a[4]++)
     for(a[5]=0;a[5]<4;a[5]++)
      for(a[6]=0;a[6]<4;a[6]++)
       for(a[7]=0;a[7]<4;a[7]++)
        for(a[8]=0;a[8]<4;a[8]++)
         for(a[9]=0;a[9]<4;a[9]++)
          if(check())
          {
           int i=1,j;
           for(i;i<=9;i++)
                 {
               if(a[i]!=0)
                  {
                for(j=0;j<a[i];j++)
                {
                 if(j!=a[i]-1)
                 cout<<i<<" ";
                 else
                 cout<<i;
                }

猜你喜欢

转载自blog.csdn.net/wlzzhcsdn/article/details/78225605
今日推荐