life02
C++博客
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
::
197 隨筆 :: 3 文章 :: 37 評論 :: 0 Trackbacks
<
2009年9月
>
日
一
二
三
四
五
六
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
常用鏈接
我的隨筆
我的評論
我參與的隨筆
留言簿
(4)
給我留言
查看公開留言
查看私人留言
隨筆分類
(179)
android ndk開發(6)
(rss)
Android開發(71)
(rss)
android面試題(4)
(rss)
android模擬器學習(7)
(rss)
android組件學習(15)
(rss)
c++學習(9)
(rss)
laucher開發(轉載)(7)
(rss)
OGRE(1)
(rss)
筆試(24)
(rss)
簡歷(6)
(rss)
算法(7)
(rss)
游戲開發(3)
(rss)
源碼學習(19)
(rss)
隨筆檔案
(197)
2012年7月 (1)
2012年4月 (13)
2012年3月 (40)
2012年2月 (20)
2012年1月 (10)
2011年12月 (47)
2011年11月 (4)
2011年10月 (1)
2011年8月 (3)
2011年7月 (1)
2011年6月 (4)
2011年3月 (1)
2011年2月 (1)
2010年12月 (4)
2010年4月 (2)
2010年2月 (1)
2009年11月 (3)
2009年10月 (16)
2009年9月 (22)
2009年8月 (3)
文章分類
(1)
轉載--OGRE(1)
(rss)
文章檔案
(3)
2010年12月 (1)
2009年9月 (1)
2009年8月 (1)
收藏夾
(16)
c++游戲開發(2)
(rss)
筆\面試經驗(5)
(rss)
筆試題(9)
(rss)
Android開發
Android 源碼
(rss)
feng88724(android)
get android source
Himi-android game
java-admin
Sunboy_2050的專欄
widebright的個人空間
八度空間 一點點技術,一點點文藝
點點
愷風(Wei)的專欄
思想實踐地
移動平臺碎碎念
c++blog——游戲
3d Game Walkman
AI_blog
AI-CODE.ORG
AI博客集合
A東亮——blog
賴勇浩的編程私伙局
牛蛙社團隊
牽著老婆滿街逛
清源游民的網絡筆記本
王者風范 浩蕩天下
業內網面試筆試綜合版
游戲程序員養成計劃
重劍無鋒,大巧不工
c++學習
A老牛
c++虛函數
編程之美
QQblog
我想我是鳥
阿里巴巴
楊爭的專欄
筆試
技術網站
AIGameDev
android 學習視頻
(rss)
http://www.mars-droid.com/
Android開發指南中文版
C/C++ Reference
CSDN
Game Programming Wiki
GameDev.NET
linux學習
sourceforge.net
STL學習
STL中文站
軟件測試
數據結構
游戲學習
游戲學習網站
搜索
最新評論
1.?re: Android開發多線程斷點續傳下載器 (轉載)
這個handler是不是只能放在外面?
還有哪些地方 。
--25Age
2.?re: An internal error occurred during: "Launching New_configuration"
這個問題,這樣解決不了啊!!!還有其他辦法木啊
--李大明
3.?re: Ubuntu 中學習 C/C++ 編程基礎入門教程
fugkgfyuk
--46546416
4.?re: IconUtilities類的createIconBitmap方法分析
分析在哪里?
--bs
5.?re: android SD卡文件的讀寫(z轉載)
不錯,有幫助
--brief
閱讀排行榜
1.?類string的構造函數、拷貝構造函數和析構函數(6502)
2.?Android中Context詳解 ---- 你所不知道的Context (轉載)(6335)
3.?RJ48線序及RJ48的自環線纜做法(6198)
4.?android控件詳解----TextView(轉載)(5451)
5.?canvas 里drawbitmap方法(5251)
評論排行榜
1.?如何判斷一點在三角形內(轉)(8)
2.?類string的構造函數、拷貝構造函數和析構函數(4)
3.?深信服筆試(轉)(4)
4.?筆試題(2)
5.?東南融通筆試題(轉)(2)
字符串循環移位 - 編程珠璣的一道題(轉)
//
編程珠璣 第二章 字符串string循環移位i位
//
eg "abcdefgh" 循環移位 3位 =》 "defghabc"
#include
<
iostream.h
>
#include
<
string
.h
>
char
*
string_cyclicshift_v2(
char
*
string
,
int
i )
{
char
ch;
int
exchange;
int
len;
exchange
=
0
;
len
=
strlen(
string
);
i
=
i
%
len;
if
(
0
==
i )
return
string
;
int
start_pos
=
0
;
while
( exchange
<
len )
{
char
ch
=
string
[start_pos];
int
currpos
=
start_pos;
int
nextpos
=
(len
+
currpos
+
i)
%
len;
while
( nextpos
!=
start_pos )
{
string
[currpos]
=
string
[nextpos];
++
exchange;
currpos
=
nextpos;
nextpos
=
(len
+
currpos
+
i)
%
len;
}
cout
<<
string
<<
endl;
string
[currpos]
=
ch;
++
exchange;
++
start_pos;
}
return
string
;
}
int
main()
{
char
string
[
7
]
=
{
'
a
'
,
'
b
'
,
'
h
'
,
'
d
'
,
'
h
'
,
'
s
'
}
;
cout
<<
string
<<
endl;
char
*
s;
s
=
string_cyclicshift_v2(
string
,
4
);
cout
<<
s
<<
endl;
return
0
;
}
要求時間復雜度空間復雜度都盡可能的低。
時間復雜度 O(n), 空間復雜度O(1),常量時間。
http://blog.csdn.net/zdl1016/archive/2009/09/21/4575309.aspx
posted on 2009-09-28 23:02
life02
閱讀(1210)
評論(1)
編輯
收藏
引用
所屬分類:
算法
評論
#
re: 字符串循環移位 - 編程珠璣的一道題(轉)[未登錄]
2011-01-14 20:31
yy
for (int i = 0; i < str_len; i++)
new_str[i] = old_str[(i+offset)%len];
回復
更多評論
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
相關文章:
字符串循環移位 - 編程珠璣的一道題(轉)
堆排序
算法的力量(轉李開復)---適合計算機專業新生
把整數分解為連續整數之和(轉)
memcpy代碼
linklist 直接插入排序
shell排序
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
Powered by:
C++博客
Copyright © life02
色综合合久久天天给综看
|
亚洲AV无码1区2区久久
|
久久久久久免费一区二区三区
|
精品免费久久久久久久
|
国产AV影片久久久久久
|
国产免费久久精品99久久
|
热久久最新网站获取
|
亚洲va久久久噜噜噜久久男同
|
国产亚洲精品美女久久久
|
久久久久国产亚洲AV麻豆
|
无码精品久久久久久人妻中字
|
99久久婷婷国产一区二区
|
久久丝袜精品中文字幕
|
麻豆亚洲AV永久无码精品久久
|
久久线看观看精品香蕉国产
|
免费无码国产欧美久久18
|
欧美久久综合性欧美
|
中文无码久久精品
|
久久久久综合中文字幕
|
久久九九有精品国产23百花影院
|
亚洲精品无码久久毛片
|
99久久综合狠狠综合久久
|
亚洲国产精品无码久久久蜜芽
|
欧美一区二区精品久久
|
国产一区二区久久久
|
国产精品午夜久久
|
国产精品视频久久
|
久久久无码一区二区三区
|
亚洲精品NV久久久久久久久久
|
国产成人无码精品久久久久免费
|
久久久久亚洲av无码专区喷水
|
狠狠色丁香婷婷久久综合
|
久久www免费人成精品香蕉
|
日本免费久久久久久久网站
|
久久久久久人妻无码
|
久久久久人妻精品一区
|
欧美丰满熟妇BBB久久久
|
久久综合九色综合网站
|
欧美亚洲国产精品久久高清
|
久久99九九国产免费看小说
|
亚洲精品97久久中文字幕无码
|