Mister-小方


私信TA

用户名:1104986125

访问量:238717

签 名:

如此英俊为哪般

等  级
排  名 3
经  验 35675
参赛次数 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编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区

我安装的是  vs 19 用scanf的时候编译的时候老是出警告。提示我换成scanf_s   换完运行后不正确   怎么改
2021-06-17 15:16:37
#include<stdio.h>
int main()
{
	char c1,c2,c3,c4,c5;
    scanf("%c%c%c%C%c",&c1,&c2,&c3,&c4,&c5);
    c1=c1+4;
    c2=c2+4;
    c3=c3+4;
    c5=c5+4;
    c4=c4+4;
    printf("%C%C%C%C%c",c1,c2,c3,c4,c5);
	return 0;
}
请问为什么是错的?
2021-05-09 11:13:13
#include <stdio.h>
main()
{ char a;
int i;
scanf("%c",&a);
while(a!='\n')
{ if(a>='a'&&a<='v'||a>='A'&&a<='V')
     printf("%c",a+4);
  else if(a>='w'&&a<='z')
        { i=a-'w';
         a='a'+i;
         printf("%c",a);
		 } 
    else if(a>='W'&&a<='Z')
		 { i=a-'W';
		 a='A'+i;
		 printf("%c",a);
		 }
   scanf("%c",&a);
}
}
2021-04-15 20:30:48
感觉不严谨。
这个程序在a到p或者A到P这个范围是有效的,但是qxyz这四个字母怎么能向后移动四位呢?
2021-04-15 20:18:30
还是这个简单
2021-04-03 10:59:48
还是这个简单
2021-04-03 10:59:36
#include <stdio.h>
int main ()
{  char c;
   while(~scanf("%c",&c))
   {  printf("%c",c+4);
   }
   return 0;
}
上个错了
2021-03-17 00:58:58
#include <stdio.h>
int main ()
{  char c;
   scanf ("%c",&c); 
   while(~scanf("%c",&c))
   {  printf("%c",c+4);
   }
   return 0;
}
为什么结果后面有【
2021-03-17 00:57:49