博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVa 101 The Blocks Problem
阅读量:6934 次
发布时间:2019-06-27

本文共 1001 字,大约阅读时间需要 3 分钟。

数据结构模拟   数据结构学的还是不扎实  参考了大神的思路。

把问题分开细化,然后再整合会吧复杂的问题简单化,思路也就不乱了。

直接上代码 (Java):

import java.util.*;public class Main101 {	public static int[] place = new int[25];	public static int[][] stack = new int[25][25]; 	public static int[] top = new int[25];	public static int[] temp = new int[25];	public static void main(String[] args) {		Scanner scan = new Scanner(System.in);		int size;		String str1,str2;		int[] res = new int[30];		while(scan.hasNext()) {			int a,b;			size = scan.nextInt();			for ( int i = 0 ; i < size ; ++ i ) {  				stack[i][0] = i;  				place[i] = i;  				top[i] = 0;  			}  			while(true) {				str1 = scan.next();				if(str1.equals("quit"))break;				a = scan.nextInt();				str2 = scan.next();				b = scan.nextInt();				if(place[a] == place[b])continue;				if(str1.equals("move")) {					pushback(a);				}				if(str2.equals("onto")) {					pushback(b);				}				move(a, b);			}			for(int i=0; i
= 0 ) { place[temp[topt]] = ID; stack[ID][++ top[ID]] = temp[topt --]; } }}

 

 

转载地址:http://digjl.baihongyu.com/

你可能感兴趣的文章
Javascript学习总结三(Array对象的用法)
查看>>
hiho_1050_树中的最长路
查看>>
Centos6.5搭建java开发环境
查看>>
08Spring_Spring和junit测试集成
查看>>
ArcGIS API for Silverlight 点沿着线流动
查看>>
在kali linux之下安装wps之后 报错字体缺失
查看>>
rem计算适配
查看>>
MySQL主主双机负载均衡
查看>>
EL与OGNL以及值栈的理解
查看>>
utf8汉字编码16进制对照(转载)
查看>>
java基础之【堆、栈、方法区】结构图
查看>>
POJ3321:Apple Tree(树状数组)
查看>>
弹出框插件layer使用
查看>>
细说 iOS 消息推送
查看>>
官方 React 快速上手脚手架 create-react-app
查看>>
位运算和典型应用详解
查看>>
微信企业号 JS-SDK:上传图片
查看>>
微信小程序尝鲜一个月现状分析
查看>>
Python命令行参数学习
查看>>
HTTP2.0探究
查看>>