Mister-小方


私信TA

用户名:1104986125

访问量:238436

签 名:

如此英俊为哪般

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

  自我简介:

TA的其他文章

解题思路以及注意事项:

  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 人评分

  评论区

#include <stdio.h>
int main(void)
{   char c1='C',c2='h',c3='i',c4='n',c5='a';
    c1='C'+4;
    c2='h'+4;
    c3='i'+4;
    c4='n'+4;
    c5='a'+4;
    printf("%c%c%c%c%c%c",c1,c2,c3,c4,c5);
    return 0;
}
请问这个最后为什么会有乱码出现
2019-12-02 23:16:43
#include<stdio.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-11-27 21:22:57
#include<stdio.h>
int main()
{
	char c1 , c2 , c3 , c4 , c5 ;

   /*scanf("%c", &c1);
	scanf("%c", &c2);
	scanf("%c", &c3);
	scanf("%c", &c4);
	scanf("%c", &c5);*/ 
	scanf("%c%c%c%c%c", &c1, &c2, &c3, &c4, &c5);
	c1 += 4; c2 += 4; c3 += 4; c4 += 4; c5 += 4;
	printf("%c%c%c%c%c\n", c1, c2, c3, c4, c5);
	return 0;
}
为什么按照下面的那种输入方式没有输出结果?
2019-11-26 19:12:10
#include<stdio.h>
int  mian(){
    char z,x,c,v,b;
	scanf("%c%c%c%c%c",&z,&x,&c,&v,&b);
    z=z+4;
     x=x+4;
      c=c+4;
       v=v+4;
        b=b+4;
        printf("%c%c%c%c%c",z,x,c,v,b);
		return 0;
}
	大神为什么我这么不行尼
2019-11-25 11:03:47
我一直好奇,w后面的四个字母怎么办,样例好像也没考虑这个问题
2019-11-23 19:12:45
#include <stdio.h> 

int main()
{
	char eng[5];
	
	int i;
	for(i=0 ;i<5 ;i++){
		scanf("%c",&eng[i]);
	}
	for(i=0 ;i<5 ;i++){
		printf("%c",eng[i]+4);
	}
	return 0;
}
2019-11-19 23:00:47
数组为社么不行
2019-11-16 13:10:04
#include <stdio.h>
int main()
{
  char c1,c2,c3,c4,c5;
  printf("请输入");
  scanf("%c%c%c%c%c\n",&c1,&c2,&c3,&c4,&c5);
  printf("c%c%c%c%c",c1+4,c2+4,c3+4,c4+4,c5+4); 
  return 0;
} 

请问大神我这个是哪里有毛病呢?
2019-10-22 19:50:08