Manchester


私信TA

用户名:wenyajie

访问量:314229

签 名:

在历史前进的逻辑中前进,这个逻辑就是人心向背的逻辑

等  级
排  名 1
经  验 62934
参赛次数 1
文章发表 188
年  龄 0
在职情况 学生
学  校 Xiamen University
专  业 计算机科学

  自我简介:

在历史前进的逻辑中前进,这个逻辑就是人心向背的逻辑

解题思路:
输入字符串,然后输出,输出的时候,遇到大写字母,输出对应的小写字母;
注意事项:
别这样写:输出超限,我的理解是,题目明确100以内字符,测试数据有超过100个字符的;
不过种思路省空间:

#include <stdio.h>

int main()
{
    char a;
    while ( (a = getchar() ) && a != '\n' )
    {
        if ( a >= 'A' && a <= 'Z' )
            printf( "%c", a + 32 );
        else
            printf( "%c", a );
    }
}


参考代码:

#include <stdio.h>
#include <string.h>
int main()
{
    char a[100];

    gets( a );
    for ( int i = 0; i < strlen( a ); i++ )
    {
        if ( a[i] >= 'A' && a[i] <= 'Z' )
            printf( "%c", a[i] + 32 );
        else
            printf( "%c", a[i] );
    }
}


 

0.0分

3 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

# include <stdio.h>
# include <string.h>
int main ()
{
	char str[100];
	gets(str);
	int i=-1;
	while(str[i]!='\0');{
		i++;
	if (str[i]>='A'&&str[i]<='z')
	str[i]+=32;}
	puts(str);
	return 0;
}
为啥错了啊
2019-12-25 19:53:30
# include <stdio.h>
# include <string.h>
int main ()
{
	char str[100];
	gets(str);
	int i=-1;
	while(str[i]!='\0');{
		i++;
	if (str[i]>='A'&&str[i]<='z')
	str[i]+=32;}
	puts(str);
	return 0;
}

为啥错了啊
2019-12-25 19:53:11
#include<stdio.h>
#include<stdlib.h>

char transform(char* arr);
int main(void)
{
	char arr[100];
	gets(arr);

	char transform(char* arr);
	
	return 0;
}

char transform(char* arr)
{
	for (int j = 0; j < 100; j++)
	{
		if (arr[j] >= 'A' && arr[j] <= 'Z')
			arr[j] += 32;
	}
	puts(arr);
	return 0;
}
这个代码的书写方式为什么错了?没有输出
2019-11-07 15:13:00
#include<stdio.h>
int main()
{
	int i=0;
char a[100];
scanf("%s",a);
while(a[i]!='\0')
{
if(a[i]>=65&&a[i]<=90)
{
	a[i]=a[i]+32;
}
i++;
}
printf("%s",a);
return 0;
}

为啥错了%12
2019-03-12 15:25:45
#include<stdio.h>
#include<string.h>
char *fun(char *a,char *b)
{
    int len=strlen(a);
    
	for(int i=0;i<len;i++)
		if(a[i]>='A'&&a[i]<='Z')
			b[i]=a[i]+32;
		else 
			b[i]=a[i];
    b[i]='\0';
	return b;
}


int main(void)
{

	char a[100],b[100];
	gets(a);
    char *p=fun(a,b); 
		
    puts(p);

	return 0;
}
为什么错误呀 ,我运行是正确结果呀!!!!!
2019-02-22 10:28:43
输出超限!原来是这个意思。
2018-12-26 10:05:21
cuo wu de   da  an!
2018-07-19 15:49:33
  • «
  • 1
  • »