【C语言求助】

飞禽走兽卍一2b 飞禽走兽卍一2b 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
(本代码目的是将输入的字符换成后面第四个字母,China——>Glmre,前面那段代码是并列执行的,便于让各位看到结果的差异,即口Glmre) 问题描述: 当独立执行第二段代码时输出:Glmre 当和第一段代码并列执行时输出:口Glmr #include <math.h> #include <stdio.h> int main(void) { //以下为并列的代码,不是主要问题 { printf("hw 3.2\n"); float way,temp; printf("请输入金额:\n"); scanf("%f",&temp); printf("请输入存款方式(1-5):\n"); scanf("%f",&way); if(way==1) { temp*=(1+5*0.03); printf("result= %f \n\n",temp); } else if(way==2) { temp*=(1+2*0.021); temp*=(1+3*0.0275); printf("result= %f \n\n",temp); } else if(way==3) { temp*=(1+3*0.0275); temp*=(1+2*0.021); printf("result= %f \n\n",temp); } else if(way==4) { temp*=pow(1.015,5); printf("result= %f \n\n",temp); } else { temp*=pow(1+0.0035/4,20); printf("result=%f \n\n",temp); } } //以下为提问的代码 { printf("hw 3.6\n"); printf("请输入五位数密码:\n"); char c[5]; int i; for(i=0;i<5;i++) //for循环输入多个字符 { c[i]=getchar(); //将输入的字符赋给变量 } for(i=0;i<5;i++) { c[i]=c[i]+4; //将输入的字符换成后面第四个 c[5]='\0'; putchar(c[i]); } putchar('\n'); } } 请大家帮忙看看是哪的问题,谢谢!
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
飞禽走兽卍一2b
C语言 70,039 成员 243,237 内容