Print a Chessboard
Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.
#.#.#.#.#. .#.#.#.#.# #.#.#.#.#. .#.#.#.#.# #.#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by ‘#’.
输入 The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.
The input ends with two 0 (when both H and W are zero).
输出 For each dataset, print the chessboard made of ‘#’ and ‘.’.
Print a blank line after each dataset.
样例输入 3 4 5 6 3 3 2 2 1 1 0 0 样例输出 #.#. .#.# #.#.
#.#.#. .#.#.# #.#.#. .#.#.# #.#.#.
#.# .#. #.#
#. .#
提示 1 ≤ H, W ≤ 300
#include<bits/stdc++.h> using namespace std; int main() { int a,b; while(cin>>a>>b) { if(a==0&&b==0) break; for(int i=1;i<=a;i++) { if(i%2==1) { for(int j=1;j<=b;j++) { if(j%2==1) cout<<"#"; else cout<<"."; } } else { for(int j=1;j<=b;j++) { if(j%2==1) cout<<"."; else cout<<"#"; } } cout<<endl; } cout<<endl; } return 0; }