码迷,mamicode.com
首页 > 其他好文 > 详细

UVA 11040 Add bricks in the wall

时间:2017-08-20 22:38:07      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:scan   names   scanf   log   clu   cst   bsp   target   ++   

https://vjudge.net/problem/UVA-11040

 

找规律

 

#include<cstdio>
using namespace std;
int a[10][10];
int main()
{
    int T,d;
    scanf("%d",&T);
    while(T--)
    {
        for(int i=1;i<=5;i++)
            for(int j=1;j<=i;j++)
                scanf("%d",&a[i*2-1][j*2-1]);
        for(int i=3;i<=9;i+=2)
        {
            for(int j=2;j<=9;j+=2)
            {
                a[i][j]=a[i-2][j-1]-a[i][j-1]-a[i][j+1]>>1;
                a[i-1][j-1]=a[i][j]+a[i][j-1];
                a[i-1][j]=a[i][j]+a[i][j+1];
            }
        }
        for(int i=1;i<=9;i++)
        {
            printf("%d",a[i][1]);
            for(int j=2;j<=i;j++) printf(" %d",a[i][j]);
            printf("\n");
        }
    }
}

 

UVA 11040 Add bricks in the wall

标签:scan   names   scanf   log   clu   cst   bsp   target   ++   

原文地址:http://www.cnblogs.com/TheRoadToTheGold/p/7401464.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!