用C语言写 一个程序 只能用pointer 不能用array

学习 时间:2026-06-05 21:06:18 阅读:2395
用C语言写 一个程序 只能用pointer 不能用array要求是把单词改写 如果单词是辅音字母开头 例如:computer 讲第一个字母放倒尾巴 并且+ay ----omputercay如果单词是元音字母开头 a e i o u例如:apple 直接加 +ay ----appleay

最佳回答

香蕉紫菜

活泼的未来

2026-06-05 21:06:18

看看吧,或许是你想要的!#include "stdio。h" char* ch_exchange(char* str) { char a; char* p; p=str; a=*p; if(!a)return str;//如果是空字符串返回 if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u') { while(*p)p++;//使p指到str的末尾 *p='a'; p++; *p='y'; p++; *p=0;//标字符串结束符号 p=str; } else { while(*p)p++; *p=a;//赋str首字母 p++; *p='a'; p++; *p='y'; p++; *p=0; p=str+1;//指到str的第二个字母开始字符串 } return p; } void main() { char ch[256]; printf("please enter the word:"); scanf("%s",ch); printf("the changed word:%s\n",ch_exchange(ch)); }

最新回答共有2条回答

  • 美丽的水池
    回复
    2026-06-05 21:06:18

    看看吧,或许是你想要的!#include "stdio。h" char* ch_exchange(char* str) { char a; char* p; p=str; a=*p; if(!a)return str;//如果是空字符串返回 if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u') { while(*p)p++;//使p指到str的末尾 *p='a'; p++; *p='y'; p++; *p=0;//标字符串结束符号 p=str; } else { while(*p)p++; *p=a;//赋str首字母 p++; *p='a'; p++; *p='y'; p++; *p=0; p=str+1;//指到str的第二个字母开始字符串 } return p; } void main() { char ch[256]; printf("please enter the word:"); scanf("%s",ch); printf("the changed word:%s\n",ch_exchange(ch)); }

上一篇 用英语怎么说我 英 语 不 这 是 写 给 四 川 理 县 孩 子 的 信、请 不 要 造

下一篇 关于算术平方根的数学题