Mister-小方


私信TA

用户名:1104986125

访问量:238835

签 名:

如此英俊为哪般

等  级
排  名 3
经  验 35690
参赛次数 1
文章发表 68
年  龄 19
在职情况 学生
学  校 大连交通大学
专  业 车辆工程

  自我简介:

TA的其他文章

解题思路以及注意事项:

  1. 注意是传参的还是定义的全局变量,不要在自定义函数中定义数组,不然函数调用结束后就会清楚数据。

  2. 注意在数组的什么地方加 '\0'。

  3. 注意不要忘了自增。

实例代码:

#include"stdio.h"
void trans(char a[],char b[]);
int main()
{
    char ch1[100],ch2[100];
    scanf("%s",ch1);
    trans(ch1,ch2);
    printf("%s",ch2);
    return 0;
}
void trans(char a[],char b[])
{
    int i=0,j=0;
    while(a[i])                           //这样写也行,可以思考下为什么
    {
        if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
        {
            b[j]=a[i];
            j++;
        }
        i++;
    }
    b[j]='\0';
}

大家还有什么不懂的请在下面评论区留言,小方会在看到的第一时间替你解疑

 

0.0分

8 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区

a[i]后面没有赋值,自动赋0?!
2020-06-17 21:10:39
不是要按aeiou顺序输出吗
2020-01-26 15:53:38
b[j]='\0'的作用是什么
2019-11-12 11:22:07
#include<stdio.h>
#include<string.h>

int main() {
	char c;
	while((c=getchar())!='\n') {
		if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') {
			printf("%c",c);
		}
	}
}
谁能帮我看下这个时间为什么会超时
2019-10-26 09:23:20
#include<stdio.h>
#include<stdlib.h>
int tremp(int* arr, int* b);

int main(void)
{
	
	int* arry = malloc(50 * sizeof(int));
	int* b2 = malloc(50 * sizeof(int));
	tremp(arry[49], b2[49]);
	return 0;
}

int tremp(int* arr, int* b)
{
	int m = 0;
	int n = 0;
	while (arr!='/t')
	{
		arr[m] = getchar();
		m++;
	}
	for (int j = 0; j < m; j++)
	{
		if (arr[j] == 'a' || arr[j] == 'e' || arr[j] == 'i' || arr[j] == 'o' || arr[j] == 'u')
		{
			b[n] = arr[j];
			n++;
		}
	}
	for (int i = 0; i < n; i++)
	{
		printf("%d", b[i]);
	}
}

有大佬能告诉我为甚么提示数组越界了吗,应该怎么样进行改动
2019-10-22 16:55:23
题目让按顺序输出,你这都没按题目要求
2019-09-09 19:55:47
b[j]='\0';这个没必要吧,直接数组初始化就完事了
2019-04-01 15:42:08
uoiea
2019-03-08 17:19:27