Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This program is a filter.
- // Input file should be fed
- // into standard input.
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- int fabric[1000][1000];
- int main( int argc, char **argv ){
- int c;
- int x, y, w, h;
- char buf[40];
- while( (c = fgetc( stdin )) != EOF ){
- fgets( buf, 40, stdin );
- strtok( buf, " " );
- strtok( NULL, " " );
- x = atoi( strtok( NULL, "," ) );
- y = atoi( strtok( NULL, ": " ) );
- w = atoi( strtok( NULL, "x" ) );
- h = atoi( strtok( NULL, "\n" ) );
- for( int i = x; i < x + w; i++ ){
- for( int j = y; j < y + h; j++ ){
- fabric[i][j]++;
- }
- }
- }
- int overlap = 0;
- for( int i = 0; i < 1000; i++ ){
- for( int j = 0; j < 1000; j++ ){
- if( fabric[i][j] >= 2 ) overlap++;
- }
- }
- printf( "%d\n", overlap );
- return 0;
- }
Add Comment
Please, Sign In to add comment