解题思路以及注意事项:
本题主要了解scanf的用法,其格式为 scanf("%d或%c或%f(这里写入你想要输入的变量的格式)",&ch(这里写你想要把输入的值赋给的变量));
一定要注意输入格式不能错,整型用%d,字符型用%c,浮点型用%f。
&一定不能掉了,掉了编译链接没问题,但运行的时候会崩溃。
实例代码:
#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() { char c1='C',c2='h',c3='i',c4='n',c5='a'; c1=c1+4; c2=c2+4; c3=c3+4; c4=c4+4; c5=c5+4; printf("%c%c%c%c%c",c1,c2,c3,c4,c5); return 0; } 是哪儿有问题?
哈哈哈哈看看我没看答案时写的~ 哈哈哈嗝~ #include "stdafx.h" int main(void){ char num[27] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\0'}; char c1,c2,c3,c4,c5; int ns = 0; scanf("%c %c %c %c %c",&c1,&c2,&c3,&c4,&c5); while(ns < 26){ switch(num[ns]){ case 'c': c1=num[ns+4]; //printf("%c\n",c1); break; case 'h': c2=num[ns+4]; //printf("%c\n",c2); break; case 'i': c3=num[ns+4]; //printf("%c\n",c3); break; case 'n': c4=num[ns+4]; //printf("%c\n",c4); break; case 'a': c5=num[ns+4];
#include<stdio.h> #include<string.h> int main() { int i; char chi; for(i=1;i<=5;) { scanf("%c",&chi); printf("%c",chi+4); i++; } return 0; }
#include<stdio.h> int main() { char c[5]; scanf("%c%c%c%c%c",&c[0],&c[1],&c[2],&c[3],&c[4]); for (int i = 0; i < 5; ++i) { printf("%c",c[i]+4); } }
qweuihqqi 2019-09-29 18:44:31 |
#include<stdio.h> int main() { char c[5]; for (int i = 0; i < 5; ++i) { scanf("%c",&c[i]); } for (int i = 0; i < 5; ++i) { printf("%c",c[i]+4); } }
char c1, c2, c3, c4, c5; scanf("%c%c%c%c%c%c", &c1, &c2, &c3, &c4, &c5); c1 = c1 + 4; c2 = c2 + 4; c3 = c3 + 4; c4 = c4 + 4; c5 = c5 + 4; printf("%c%c%c%c%c%c",c1,c2,c3,c4,c5); return 0; 这个为什么不对啊?
#include<stdio.h> int main() { char ch1, ch2, ch3, ch4, ch5; scanf("%C%C%C%C%C%C",&ch1,&ch2,&ch3,&ch4,&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; } 为什么编译没错误 可就是你运行不出来
风寂 2019-09-27 17:29:17 |
大小写啊兄弟 cC
请问这个出现什么问题了? #include <stdio.h> int main() { char c1, c2, c3, c4, c5; scanf_s("%c%c%c%c%c", &c1, &c2, &c3, &c4, &c5); printf("%c%c%c%c%c%", c1+4, c2+4, c3+4, c4+4, c5+4); }
生活追求者 2019-10-21 21:32:44 |
我跟你写的一模一样
Vh暖夏 2019-11-21 15:15:26 |
题目说是输入China输出Glmre,但是你调试一下这个代码会发现你这个代码不需要输入(也就是不需要自己打字:China),直接就出Glmre这个答案了,当然错了。你必须定义char a,b,c,d,e;然后使用scanf这个函数一个一个赋值。