1. 程式人生 > >每日一題 uva-232 模擬+輸出要求很嚴格

每日一題 uva-232 模擬+輸出要求很嚴格

per war warning con print pan clas i++ one

https://cn.vjudge.net/problem/UVA-232

uva的題,結尾不能多\n,空格什麽的

反正就是個中型模擬,題目多讀就行

#define _CRT_SECURE_NO_WARNINGS
#include    <cmath>
#include <iostream>
#include    <stdio.h>
#include<algorithm>
#include        <map>
#include     <cstring>
#include      <time.h>
#include      
<string> #include<set> using namespace std; #define rep(i,t,n) for(int i =(t);i<=(n);++i) #define per(i,n,t) for(int i =(n);i>=(t);--i) #define mmm(a,b) memset(a,b,sizeof(a)) const int maxn = 2e5+ 5; const long long mod = 998244353; int n,m; char s[15][15]; int id[15][15]; int vis[15
][15]; int main() { int kase = 0; int first = 1; while (cin>>n&&n) { if (first)first = 0;else printf("\n"); cin >> m; mmm(id, 0); printf("puzzle #%d:\n", ++kase); rep(i, 1, n)cin >> s[i]+1; int idx = 0; rep(i,
1, m)if (s[1][i] != *)id[1][i] = ++idx; rep(i, 2, n)rep(j, 1, m) { if (s[i][j]!=*&&(j == 1 || s[i - 1][j] == * || s[i][j - 1] == *))id[i][j] = ++idx; } puts("Across"); rep(i, 1, n)rep(j, 1, m) if(s[i][j]!=*){ printf("%3d.", id[i][j]); while (s[i][j] != *&&j<=m) { cout << s[i][j]; j++; } cout << endl; } puts("Down"); mmm(vis, 0); rep(i, 1, n)rep(j, 1, m) if (s[i][j] != *&&!vis[i][j]) { printf("%3d.", id[i][j]); int ii = i; while (s[ii][j] != *&&ii <= n) { cout << s[ii][j]; vis[ii][j] = 1; ii++; } cout << endl; } //cout << endl; } } /* 2 2 AT *O 6 7 AIM*DEN *ME*ONE UPON*TO SO*ERIN *SA*OR* IES*DEA 1 1 * */

每日一題 uva-232 模擬+輸出要求很嚴格