uva1605
題意:設(shè)計(jì)一棟有n層的樓,每層都有m行k列的格子,將這些格子分給不同的國家,使得每個(gè)國家都有相鄰的格子。
分析:方法很多,因?yàn)橄拗坪苌?#xff0c;剛開始想復(fù)雜了,其實(shí)只需要考慮以最簡單的方法將它們兩兩相鄰就好了。
#include<iostream> #include<string> #include<sstream> #include<algorithm> #include<vector> using namespace std;int main() {int n;char w[] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" };while (cin >> n) {cout << "2 " << n << " " << n << endl;for (int i = 0; i < n; i++) {for (int j = 0; j < n; j++) {cout << w[i];}cout << endl;}cout << endl;for (int i = 0; i < n; i++) {for (int j = 0; j < n; j++) {cout << w[j];}cout << endl;}}return 0; }?
總結(jié)