zoukankan
html css js c++ java
Hanoi代码 暑期学习笔记(六)
Code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
Hanoi
{
class
Program
{
static
void
Main(
string
[] args)
{
Program p
=
new
Program();
int
n
=
int
.Parse(Console.ReadLine());
p.hanoi(n,
'
A
'
,
'
C
'
,
'
B
'
);
Console.ReadLine();
}
private
void
hanoi(
int
n,
char
s,
char
d,
char
t)
{
if
(n
==
1
)
{ Console.Write(
"
{0}->{1}\t
"
, s, d);
return
; }
hanoi(n
-
1
, s, t,d);
Console.Write(
"
{0}->{1}\t
"
, s, d);
hanoi(n
-
1
, t, d,s);
return
;
}
}
}
好无聊,看奥运的时候心血来潮,就写下来了。
作者:
KKcat
出处:
http://jinzhao.cnblogs.com/
个人博客:
http://jinzhao.me/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
查看全文
相关阅读:
Roads in the North
Labyrinth
英语写作(二)
语法长难句笔记
英语写作(一)
MySQL笔记(二)
MySQL笔记(一)
Mybatis简单使用与配置
Mybatis映射文件
什么是serializable接口?
原文地址:https://www.cnblogs.com/jinzhao/p/1269802.html
最新文章
小程序之横向滚动
uni-app发布体验版本后授权登录很卡
electron 页面调用require() 的时候,提示require undefined
nodejs linux 环境变量配置
pip 或 pip3更换源为国内源
npm更换成淘宝的源
python struct pack() unpack
UDP
TCP
icmp
热门文章
ipv4
python socket
背包问题汇总
The King’s Ups and Downs
what is your grade?
钱币兑换问题
A计划
变形课
Tempter of the Bone
Sudoku POJ-2676
Copyright © 2011-2022 走看看