比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 C
题目名称 Asm.Def的命令 最终得分 0
用户昵称 StanTia 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2015-10-31 11:44:51
显示代码纯文本
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
struct point
{
	int x;	//10*x
	int y;	//10*y
	
	void get()
	{
		cout<<x/10<<"."<<x%10;
		cout<<" ";
		cout<<y/10<<"."<<y%10;
		cout<<endl;
	}
	void up_down(int x,int y)
	{
		this->x += 10*x;
		this->y += 10*y;
	}
};

point* men;
string* key;

int num_people;
int num_key;

void init()
{

	cin>>num_people>>num_key;
	
	men = new point[num_people];
	key = new string[num_key];
	
	for(int i = 0; i< num_people; i++)
	{
		men[i].x = 0;
		men[i].y = 10 * i;
	}
	for(int i = 0; i< num_key; i++)
	{
		cin>>key[i];
	}
}

void run(string key)
{
	
	int index_begin = 0;
	int index_end = 0;
	int index = 0;
	
	int key_num = 0;
	string key_sub[5] = {"","","","",""};
	int key_use[5] = {0,0,0,0,0};
	
	for(string::iterator iter = key.begin();iter != key.end();iter++,index++)
	{
		if((*iter) == ' ')
		{
			index_end = index - 1;
			key_sub[key_num] = key.substr(index_begin,index_end);
			index_begin = index + 1;
			//printf("key_sub %d: %s",key_num,key_sub[key_num]);
		}
	}
	for(int i = 0; i < 5; i++)
	{
		key_use[i] = atoi(key_sub[i].c_str());
	}
	//printf("Key_use:\n");
	//printf("1:%d\n2:%d\n3:%d\n4:%d\n5:%d\n\n\n\n",key_use[0],key_use[1],key_use[2],key_use[3],key_use[4]);
	switch (key_use[0])
	{
		case 0: men[1].get(); break;
		case 1: 
			for(int i = key_use[1]; i<= key_use[2];i++)
			{
				men[i].up_down(key_use[3],key_use[4]);
			}
			break;
	}
}

int main()
{
	freopen("asm_command.in","r",stdin);
	freopen("asm_command.out","w",stdout);
	init();
	for(int i = 0;i < num_key; i++)
	{
		run(key[i]);
	}

}