统计斜杠出现了奇数次还是偶数次
Long time ago, most of PCs were equipped with video cards that worked only in text mode. If theprogrammer wanted to show a picture on a screen, he had to use pseudographics or ASCII art like this:^..^(OO)/ \()()In this problem you are given a polygon, drawn using ASCII art. Your task is to calculate its area.The picture is formed using characters ‘.’, ‘\’, and ‘/’. Each character represents a unit square of thepicture. Character ‘.’ represents an empty square, character ‘/’ — a square with a segment from thelower left corner to the upper right corner, and character ‘\’ — a square with a segment from the upperleft corner to the lower right corner./\/\\../.\.\..\/InputThe first line of the input file contains integer numbers h and w (2 ≤ h, w ≤ 100) — height and width ofthe picture. Next h lines contain w characters each — the picture drawn using ASCII art.It is guaranteed that the picture contains exactly one polygon without self-intersections and self-touches.OutputPrint to the output file one integer number — the area of the polygon.Sample input and outputascii.in ascii.out4 4/\/\\../.\.\..\/8Page 1 of 16ACM ICPC 2011–2012, Northeastern European R
/* ***********************************************
Author :CKboss
Created Time :2015年02月02日 星期一 10时27分48秒
File Name :POJ4022.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
int h,w;
char mp[200][200];
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(scanf("%d%d",&h,&w)!=EOF)
{
memset(mp,0,sizeof(mp));
for(int i=0;i<h;i++)
{
scanf("%s",mp[i]);
}
int area = 0;
for(int i=0;i<h;i++)
{
int temp = 0;
for(int j=0;j<w;j++)
{
if(mp[i][j]=='\\'||mp[i][j]=='/')
{
temp++; area+=1;
}
else if(mp[i][j]=='.')
{
if(temp%2) area+=2;
}
}
}
printf("%d\n",area/2);
}
return 0;
}