#include <stdio.h>
#include <string.h>
#include <ctype.h>
void fun(char a[],char b[])
{int i// j多写了
for(i=strlen(a)-1i>=0i--)
if((i==0||!isalpha(a[i-1]))&&isalpha(a[i]))
{strcat(b,&a[i])
strcat(b," ")// 这样写即可
if(i) // i == 0时不能执行下步操作没有这句在vc2005等严谨的ide中调试时会报错
a[i-1]=0
}
}
void main(){
char a[]="i am you"
char b[10]
int i
for(i=0i<10i++)
b[i]=0
puts(a)
fun(a,b)
puts(b)
}
顺便说下 回答者: jiankunsmile - 助理 三级 的根本就是乱搞..
日本人也叫人...
#include <stdio.h>#include <stdlib.h>
#include <string.h>
int main(void)
{
char *p
char c[] = " "
char s[1024],*t,z[1024]
int flag = 1
while(gets(s)){
if(s[0] == '#'){
}
else if(s[0] != '#'){
p = strtok(s,c)
while(p){
t = strrev(p)
strcat(z,t)
strcat(z," ")
p=strtok(NULL,c)
}
strcat(z,"\n")
}
}
printf("%s",z)
}
#include<stdio.h>#include<string.h>
void a(char *p)
{
char temp[100]
int b = strlen(p)
int k = 0
char temp1[100]
int i = 0
for(i=0i<bi++)
{
temp[i]=p[b-i-1]
}
temp[b]='\0'
puts(temp)
int j = 0
//要循环结束条件为: j <= b
for(j=0j<=bj++)
{
//此处应为判断,用 '==',还要考虑句尾的情况,要不最后一个单词打印不出来
if(temp[j]==' ' || temp[j] == '\0')
{
int l = 0
for(k<jk++)
{
temp1[k]=temp[j-l-1]
l++
}
//在单词之间添加空格
temp1[j] = ' '
k++
}
}
temp1[b]='\0'
puts(temp1)
}
int main()
{
char ch[100]
printf("zifushuan\n")
gets(ch)
a(ch)
return 0
}
运行截图:
希望这能够帮助你