I finally got my question...
Although this question is not difficult, you should pay attention to it.
There may be spaces. Therefore, Getline gets must be used to read data that cannot be read by CIN scanf.
In addition to these () characters in the question, + these four characters are used for judgment! (CH> = '0' & Ch <= '9') to determine
Because the data is very small, only 1000 of the data is scanned. The variable array vis is used to indicate whether it has been scanned. Then, a grid is scanned and a grid is used to calculate the total area.
...... Can CF let me release c d at night? Dare not!
1 #include <iostream> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 const int size = 520; 7 char str[size]; 8 int matrix[size]; 9 bool vis[size*2][size*2];10 bool judge( char ch )11 {12 if( ch>=‘0‘ && ch<=‘9‘ )13 return false;14 return true;15 }16 17 int main()18 {19 int i , len , cnt , ans;20 while( gets(str) )21 {22 ans = i = 0;23 cnt = 1;24 len = strlen(str);25 memset( matrix , 0 , sizeof(matrix) );26 memset( vis , false , sizeof(vis) );27 while( i<len )28 {29 if( judge(str[i]) )30 {31 i++;32 }33 else34 {35 while(1)36 {37 if( judge(str[i]) )38 break;39 matrix[cnt] = matrix[cnt]*10+(str[i]-‘0‘);40 i++;41 }42 cnt ++;43 }44 }45 for( int i = 0 ; i<cnt/4 ; i++ )46 {47 int x1 = matrix[i*4+1];48 int y1 = matrix[i*4+2];49 int x2 = matrix[i*4+3];50 int y2 = matrix[i*4+4];51 int maxX = max(x1,x2);52 int maxY = max(y1,y2);53 for( int x = min(x1,x2)+1 ; x<=maxX ; x++ )54 {55 for( int y = min(y1,y2)+1 ; y<=maxY ; y++ )56 {57 if( !vis[x][y] )58 {59 vis[x][y] = true;60 ans ++;61 }62 }63 }64 }65 cout << ans << endl;66 }67 return 0;68 }View code
It seems that the token is not updated in 2 days =-=
Today:
Talking about harmony and discord between teenagers and adults