Codeforces Round #290 (Div. 2) A. Fox And Snake(模拟)
题目链接:https://codeforces.com/contest/510/problem/A
题意:
用'.'和'#'输出蛇状图形。
思路:
需要找下规律的模拟题。
#include <bits/stdc++.h> using namespace std; const int M=60; int main() { int n,m;cin>>n>>m; char MP[M][M]={}; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(i&1) MP[i][j]='#'; else if( (i/2&1)&&j==m) MP[i][j]='#'; else if(!(i/2&1)&&j==1) MP[i][j]='#'; else MP[i][j]='.'; } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cout<<MP[i][j]; } cout<<"\n"; } return 0; }

浙公网安备 33010602011771号