正题
大意
给出一块黑块和白块组成的版,将其旋转90°后和之前的黑块叠加,求最初始和每次旋转后的黑块数。
解题思路
暴力模拟不解释
代码
#include<cstdio>
#include<iostream>
using namespace std;
int n,s;
char c[51][51],a[51][51];
int main()
{scanf("%d",&n);for (int i=1;i<=n;i++)for (int j=1;j<=n;j++){cin>>c[i][j];if (c[i][j]=='1') s++;}printf("%d\n",s);for (int k=1;k<=3;k++){s=0;for (int i=1;i<=n;i++)for (int j=1;j<=n;j++){a[j][n-i+1]=c[i][j];}for (int i=1;i<=n;i++){for (int j=1;j<=n;j++){if (c[i][j]=='0')c[i][j]=a[i][j];if (c[i][j]=='1') s++;}}printf("%d\n",s);}
}