gpt4 book ai didi

c - 如何垂直打印该字符串

转载 作者:行者123 更新时间:2023-11-30 21:05:03 25 4
gpt4 key购买 nike

我被指派制作一个程序,该程序将输出用户的消息:反转、垂直和垂直颠倒。我完全意外地垂直颠倒了,但现在我无法弄清楚垂直方向。

include <stdio.h>
#include <stdlib.h>
#include <string.h>

main(){
char str[100];
int i, len;

printf("Enter a message \n");
gets(str);
len =strlen(str);
printf("The message reversed: \n");
for(i = len - 1; i >= 0; i--)
{
printf("%c", str[i]);
}
printf("\n");

printf("The message vertical upside down \n");

for(i = len - 1; i >= 0; i--){
printf("%c \n", str[i]);
}


printf("\n");
system("pause");
}

能够垂直输出消息,并在垂直颠倒不正确时进行更正。

最佳答案

怎么样?

for (i = 0; i < len; i++) {
printf("%c\n", str[i]);
}

关于c - 如何垂直打印该字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56879780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com