首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

《程序设计引向及在线实践》学习

2012-08-24 
《程序设计导引及在线实践》学习P41int MyItoa(char s[])将s中以字符串形式存放的非负整数,转换成相应整数返

《程序设计导引及在线实践》学习

P41

int MyItoa(char s[])

将s中以字符串形式存放的非负整数,转换成相应整数返回。

#include<stdio.h>#include<string.h>char result[101];// step: positive--right move, negative--left move char* moveReplace(char* s, int step){int i;for(i=0; i<strlen(s); i++){if(*(s+i)+step > 'Z'){result[i] = 'A' + (*(s+i) + step - 'Z' - 1);}else if(*(s+i)+step < 'A'){result[i] = 'Z' + (*(s+i) - 'A' + step + 1);}else{result[i] = *(s+i) + step;}}result[i] = '\0';return result;}int main(){char s[10] = "ABCXYZ";printf("%s\n",moveReplace(s,-2));}
?

?

?

?

?

?

热点排行