抛砖引玉啊亲,你可懂?

Edsger Dijkstra:算法+数据结构=程序
程序代码:#include <stdio.h>
int main(void)
{
char a[100] = {'\0'};
int i,k;
char ch;
int o,z;
printf("输入一段字符串按回车结束!\n");
scanf("%s",a);
printf("请输入在字符什么位置开始截取!\n");
scanf("%d",&i);
printf("请输入截取数!\n");
scanf("%d",&k);
if(k & 1)
{
for(o = 0; o < (k-1)/2 ;o++)
{
ch = a[o];
a[o+((k%2)+(k/2))] = ch;
}
}else{
for(o = 0,z = k/2; o < z ;o++,k--)
{
ch = a[o];
a[k] = ch;
}
}
printf("%s",a);
return 0;
}
程序代码:#include<stdio.h>
#include<stdlib.h>
#define LENGTH 100
void work(char str[],int start)
{
char *p=NULL,*s=NULL,ctemp;
p=s=str; //指针p和s指向str
s=s+start-1; //开始逆序操作的位置
p=s+4; //终止逆序操作的位置
while(s<p) //执行逆序操作
{
ctemp=*s;
*s++=*p;
*p--=ctemp;
}
}
int main()
{
int n;
char mystr[LENGTH];
printf("请输入字符串:"); scanf("%s",mystr);
printf("请输入起始值:"); scanf("%d",&n);
work(mystr,n); //调用自定义逆序函数work执行逆序操作
puts(mystr); //输出逆序后的字符串
system("pause");
return 0;
}