[問題] UVA 10189
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
踩地雷簡單題,因為懶得用二維陣列去做就去網路上找用map寫法的
看到有一個是寫成以下這樣
#include<iostream>
#include<map>
using namespace std;
int n1,n2,h=1;
int main(){
while(cin>>n1>>n2&&n1!=0&&n2!=0)
{ if(h>1){cout<<endl;}
map<int,map<int,char> >a;
for(int i=0;i<n1;i++)
{
for(int ii=0;ii<n2;ii++)
{
cin>>a[i][ii];
}
}
cout<<"Field #"<<h<<":"<<endl;
for(int i=0;i<n1;i++,cout<<endl)
{
for(int ii=0;ii<n2;ii++)
{
if(a[i][ii]=='*'){cout<<"*"; continue;}
#define A(R,C) (a[R][C]=='*')
int ans=A(i-1,ii-1)+A(i-1,ii)+A(i-1,ii+1)
+A(i,ii-1)+A(i,ii)+A(i,ii+1)
+A(i+1,ii-1)+A(i+1,ii)+A(i+1,ii+1);
cout<<ans;
}
}
h++;
}
}
想請問 #define A(R,C) (a[R][C]=='*')
int ans=A(i-1,ii-1)+A(i-1,ii)+A(i-1,ii+1)
+A(i,ii-1)+A(i,ii)+A(i,ii+1)
+A(i+1,ii-1)+A(i+1,ii)+A(i+1,ii+1);
這一整段是啥意思?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.233.66.79
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1428325588.A.724.html
推
04/06 21:40, , 1F
04/06 21:40, 1F
→
04/06 21:41, , 2F
04/06 21:41, 2F
※ 編輯: ssadd502227 (36.233.66.79), 04/06/2015 21:48:04
→
04/06 21:45, , 3F
04/06 21:45, 3F
→
04/06 21:48, , 4F
04/06 21:48, 4F
→
04/06 21:55, , 5F
04/06 21:55, 5F
→
04/06 21:55, , 6F
04/06 21:55, 6F
→
04/06 21:55, , 7F
04/06 21:55, 7F
→
04/06 21:56, , 8F
04/06 21:56, 8F
→
04/06 22:11, , 9F
04/06 22:11, 9F
→
04/06 22:19, , 10F
04/06 22:19, 10F
→
04/06 22:20, , 11F
04/06 22:20, 11F
→
04/06 22:25, , 12F
04/06 22:25, 12F
→
04/06 22:25, , 13F
04/06 22:25, 13F
→
04/06 22:25, , 14F
04/06 22:25, 14F
→
04/06 23:21, , 15F
04/06 23:21, 15F
推
04/07 00:15, , 16F
04/07 00:15, 16F
推
04/07 02:13, , 17F
04/07 02:13, 17F
→
04/07 09:37, , 18F
04/07 09:37, 18F
→
04/07 09:37, , 19F
04/07 09:37, 19F
→
04/07 09:38, , 20F
04/07 09:38, 20F
→
04/07 09:49, , 21F
04/07 09:49, 21F
→
04/07 09:50, , 22F
04/07 09:50, 22F
→
04/07 09:52, , 23F
04/07 09:52, 23F
推
04/07 11:40, , 24F
04/07 11:40, 24F
→
04/07 11:41, , 25F
04/07 11:41, 25F
→
04/07 11:41, , 26F
04/07 11:41, 26F
推
04/07 12:45, , 27F
04/07 12:45, 27F
推
04/07 15:54, , 28F
04/07 15:54, 28F
→
04/07 15:54, , 29F
04/07 15:54, 29F
→
04/07 15:55, , 30F
04/07 15:55, 30F
→
04/07 15:55, , 31F
04/07 15:55, 31F
→
04/07 15:56, , 32F
04/07 15:56, 32F
→
04/07 15:58, , 33F
04/07 15:58, 33F
→
04/07 15:59, , 34F
04/07 15:59, 34F
→
04/07 16:00, , 35F
04/07 16:00, 35F
→
04/07 16:01, , 36F
04/07 16:01, 36F
推
04/07 16:32, , 37F
04/07 16:32, 37F
→
04/07 17:15, , 38F
04/07 17:15, 38F
還有 21 則推文
→
04/07 21:43, , 60F
04/07 21:43, 60F
→
04/07 21:44, , 61F
04/07 21:44, 61F
→
04/07 21:45, , 62F
04/07 21:45, 62F
→
04/07 21:45, , 63F
04/07 21:45, 63F
→
04/07 21:45, , 64F
04/07 21:45, 64F
→
04/07 22:05, , 65F
04/07 22:05, 65F
→
04/07 22:06, , 66F
04/07 22:06, 66F
→
04/07 22:08, , 67F
04/07 22:08, 67F
→
04/07 22:17, , 68F
04/07 22:17, 68F
→
04/07 22:17, , 69F
04/07 22:17, 69F
→
04/07 22:18, , 70F
04/07 22:18, 70F
→
04/07 22:18, , 71F
04/07 22:18, 71F
→
04/07 22:34, , 72F
04/07 22:34, 72F
→
04/08 00:35, , 73F
04/08 00:35, 73F
→
04/08 00:36, , 74F
04/08 00:36, 74F
→
04/08 00:36, , 75F
04/08 00:36, 75F
→
04/08 00:37, , 76F
04/08 00:37, 76F
→
04/08 00:37, , 77F
04/08 00:37, 77F
→
04/08 00:37, , 78F
04/08 00:37, 78F
→
04/08 00:38, , 79F
04/08 00:38, 79F
→
04/08 00:38, , 80F
04/08 00:38, 80F
→
04/08 00:46, , 81F
04/08 00:46, 81F
→
04/08 00:47, , 82F
04/08 00:47, 82F
→
04/08 00:48, , 83F
04/08 00:48, 83F
→
04/08 00:48, , 84F
04/08 00:48, 84F
→
04/08 01:07, , 85F
04/08 01:07, 85F
→
04/08 01:07, , 86F
04/08 01:07, 86F
→
04/08 01:08, , 87F
04/08 01:08, 87F
→
04/08 09:30, , 88F
04/08 09:30, 88F
→
04/08 09:31, , 89F
04/08 09:31, 89F
→
04/08 09:32, , 90F
04/08 09:32, 90F
→
04/08 09:33, , 91F
04/08 09:33, 91F
→
04/08 09:34, , 92F
04/08 09:34, 92F
→
04/08 09:34, , 93F
04/08 09:34, 93F
→
04/08 09:34, , 94F
04/08 09:34, 94F
→
04/08 09:35, , 95F
04/08 09:35, 95F
→
04/08 09:41, , 96F
04/08 09:41, 96F
→
04/08 09:41, , 97F
04/08 09:41, 97F
→
04/08 13:20, , 98F
04/08 13:20, 98F
→
04/08 13:20, , 99F
04/08 13:20, 99F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章