ВУЗ:
Составители:
Рубрика:
inf>>n;
std::string s;
getline(inf,s);
int x=0,y=0;
coords.push_back(point(0,0));
for (int i=0;i<n;++i)
{
getline(inf,s);
char c=s[0];
dirs.push_back(c);
switch(c)
{
case 'N':++y;break;
case 'S':--y;break;
case 'E':++x;break;
case 'W':--x;break;
default:
std::cerr<<"Error in input file!\n";
outf<<"Error in input file!\n";
return 1;
}
coords.push_back(point(x,y));
}
unsigned int idx=0;
while(idx<coords.size())
{
if (idx>0) {std::cout<<dirs[idx-1];outf<<dirs[idx-1];}
unsigned int tmp=coords.size()-1;
while(tmp>idx)
if (coords[tmp]==coords[idx])
{ idx=tmp;break;}
else --tmp;
++idx;
}
return 0;
}
Страницы
- « первая
- ‹ предыдущая
- …
- 64
- 65
- 66
- 67
- 68
- …
- следующая ›
- последняя »