Mister-小方


私信TA

用户名:1104986125

访问量:238804

签 名:

如此英俊为哪般

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

  自我简介:

解题思路以及注意事项:

  1. 本题主要了解scanf的用法,其格式为            scanf("%d或%c或%f(这里写入你想要输入的变量的格式)",&ch(这里写你想要把输入的值赋给的变量));

  2. 一定要注意输入格式不能错,整型用%d,字符型用%c,浮点型用%f。

  3. &一定不能掉了,掉了编译链接没问题,但运行的时候会崩溃。

实例代码:

#include"stdio.h"
int main()
{
    char ch1,ch2,ch3,ch4,ch5;
    scanf("%c",&ch1);
    scanf("%c",&ch2);
    scanf("%c",&ch3);
    scanf("%c",&ch4);
    scanf("%c",&ch5);
    printf("%c%c%c%c%c",ch1+4,ch2+4,ch3+4,ch4+4,ch5+4);
    return 0;
}

有什么不懂的可以在评论区评论

 

0.0分

210 人评分

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

编程语言转换

万能编程问答

代码解释器

  评论区

#include<stdio.h>
int main()
{
    char ch1,ch2,ch3,ch4,ch5;
    scanf("%c",&ch1);
    scanf("%c",&ch2);
    scanf("%c",&ch3);
    scanf("%c",&ch4);
    scanf("%c",&ch5);
       ch1=ch1+4;
       ch2=ch2+4;
       ch3=ch3+4;
       ch4=ch4+4;
       ch5=ch5+4;
    printf("%c%c%c%c%c",ch1,ch2,ch3,ch4,ch5);
    return 0;
}
为什么我这个也不行
2020-02-07 12:02:50
这样为啥不行呢?
#include<stdio.h>

int main()
{   
    char c1,c2,c3,c4,c5;
    
    printf("请输入密码:\n");
    
    scanf("%c%c%c%c%c",&c1,&c2,&c3,&c4,&c5);
    printf("%c%c%c%c%c\n",c1+4,c2+4,c3+4,c4+4,c5+4);
    
    return 0;
}
2020-01-19 14:05:00
#include<stdio.h>
#define i 100
int main()
{
    char a[i];
    gets(a);

    while(1){
        a[i]=a[i]+4;
        if(i=='\n'||i=='\0'){
            a[i]==0;
            break;
        }
        puts(a);
    }

    return 0;
}
有哪位兄弟帮我纠下错吗?在下感激不尽
2020-01-13 21:15:44
#define _CRT_SECURE_NO_WARNINGS
int main(void)
{
	char c1, c2, c3, c4, c5;
	scanf("%c", &c1);
	scanf("%c", &c2);
	scanf("%c", &c3);
	scanf("%c", &c4);
	scanf("%c", &c5);
	printf("%c%c%c%c%c", c1 + 4, c2 + 4, c3 + 4, c4 + 4, c5 + 4);
	return 0;
}
2020-01-02 17:24:18
#include<stdio.h>
int main()
{
    char a[5];
    int i;
    for(i=0;i<=4:i++)
    {
    scanf("%c\n",&a[i]);
    printf("%c\n",a[i]+4);
    }
    return 0;
}
为什么不行?
2019-12-21 17:45:36
#include<stdio.h>
int main()
{
    char a[6];
    gets(a);
    char *p;
    p=a;
    for(;p<a+5;p++)
    printf("%c",*p+4);
    return 0;
}
2019-12-13 21:55:24
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch1,ch2,ch3,ch4,ch5;
    scanf("%c%c%c%c%c",&ch1,&ch2,&ch3,&ch4,&ch5);
    printf("%c%c%c%c%c",ch1+4,ch2+4,ch3+4.ch4+4,ch5+4);
    return 0;
}
我这个哪里错了呢
2019-12-05 11:17:06
#include <stdio.h>
int main()
{char a[100];
char b[100];
int i=0,j=0;
for (i=0;a[i]!='\n';i++){
	scanf("%c",&a[i]);
}
for (j=0;a[j]!='\n';j++){
	b[j]=a[j]+4;
	printf("%c",b[j]);
}
return 0;
}
请问我这段代码哪里错了呢?
2019-12-03 15:34:16