bnuoj 27987 Record of the Attack at the Orbit (模拟)

http://www.bnuoj.com/bnuoj/problem_show.php?pid=27987

【题意】:给定坐标输出图形

【题解】:处理坐标上的小技巧

【code】:

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <string.h>
 4 #include <math.h>
 5 
 6 using namespace std;
 7 
 8 #define N 100
 9 
10 char str[N*3][N*3];
11 
12 void init()
13 {
14     int i,j;
15     for(i=0;i<250;i++)
16     {
17         for(j=0;j<250;j++)
18         {
19             str[i][j]='.';
20             if(i==100)
21             {
22                 str[i][j]='-';
23             }
24             if(j==100)
25             {
26                 str[i][j]='|';
27             }
28             if(i==100&&j==100)
29             {
30                 str[i][j]='+';
31             }
32         }
33     }
34 }
35 
36 int main()
37 {
38     int t;
39     scanf("%d",&t);
40     init();
41     int x1=1000,y1=1000,x2=-1,y2=-1;
42     while(t--)
43     {
44         int x,y;
45         scanf("%d%d",&y,&x);
46         x=-x;
47         x+=100;
48         y+=100;
49         if(x1>x)    x1=x;
50         if(y1>y)    y1=y;
51         if(x2<x)    x2=x;
52         if(y2<y)    y2=y;
53         str[x][y]='*';
54     }
55     if(x1>100)  x1=100;
56     if(y1>100)  y1=100;
57     if(x2<100)  x2=100;
58     if(y2<100)  y2=100;
59     int i,j;
60     for(i=x1;i<=x2;i++)
61     {
62         for(j=y1;j<=y2;j++)
63         {
64             putchar(str[i][j]);
65         }
66         putchar(10);
67     }
68     return 0;
69 }
原文地址:https://www.cnblogs.com/crazyapple/p/3342963.html