请编程序将“China”译成密码,密码规律是:用原来字母后面第4个字母代替原来的字母。分别用putchar和printf函数输出这5个字符。

程序:

#include<stdio.h>

int main()

{

char c1='C',c2='h',c3='i',c4='n',c5='a';

c1 += 4;

c2 += 4;

c3 += 4;

c4 += 4;

c5 += 4;

printf("用printf输出密码为:%c%c%c%c%c\n", c1, c2, c3, c4, c5);

printf("用putchar输出密码为:");

putchar(c1);

putchar(c2);

putchar(c3);

putchar(c4);

putchar(c5);

printf("\n");

return 0;

}

结果:

用printf输出密码为:Glmre

用putchar输出密码为:Glmre

请按任意键继续. . .


本文出自 “岩枭” 博客,请务必保留此出处http://yaoyaolx.blog.51cto.com/10732111/1740254

Logo

聚焦前沿AI与大模型技术探索,汇聚开发者及爱好者,共享开源项目、学习资源与行业资讯。

更多推荐