码迷,mamicode.com
首页 > 其他好文 > 详细

*字符串-05. 字符串循环左移

时间:2014-08-19 23:52:05      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   ar   

 1 /*
 2  * Main.c
 3  * D5-字符串-05. 字符串循环左移
 4  *  Created on: 2014年8月19日
 5  *      Author: Boomkeeper
 6  ********部分通过*******
 7  */
 8 
 9 #include <stdio.h>
10 
11 int main(void){
12 
13     char str[100]={0};
14     int N=0;
15     int endIndex=99;//字符串的结尾标识符
16 
17     gets(str);
18     scanf("%d",&N);
19     //确定字符串结尾的位置
20     int k;
21     for(k=0;k<100;k++){
22         if(str[k]==\0){
23             endIndex=k;
24             break;
25         }
26     }
27     //将N限制在字符串长度范围内
28     while(N>endIndex){
29         N=N%(endIndex+1);
30     }
31     //输出N右边的字符
32     int i;
33     for(i=N;i<endIndex;i++){
34         putchar(str[i]);
35     }
36     //输出N左边的字符
37     int j;
38     for(j=0;j<N;j++){
39         putchar(str[j]);
40     }
41     return 0;
42 }

 bubuko.com,布布扣

 题目链接:

http://pat.zju.edu.cn/contests/basic-programming/%E5%AD%97%E7%AC%A6%E4%B8%B2-05

.

*字符串-05. 字符串循环左移,布布扣,bubuko.com

*字符串-05. 字符串循环左移

标签:style   blog   http   color   os   io   for   ar   

原文地址:http://www.cnblogs.com/boomkeeper/p/D5.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!