C帮助 - 输出拼写输入字母

时间:2016-11-30 04:25:31

标签: c

我正在试图弄清楚C拼出一个给定单词的最佳方法。我已经反过来拼写了给定的单词。

输入:测试

输出:

ë

取值

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

void reverse(char [], int, int);
int main()
{
char str1[12];
int size, counter;

printf("Enter a string to reverse: ");
scanf("%s", str1);
printf("string1 with each character on a new line:")


printf("string1 printed backwards: \n");
size = strlen(str1);
reverse(str1, 0, size - 1);
printf("The string after reversing is: %s\n", str1);
return 0;
}

void reverse(char str1[], int index, int size) 
{ // Reversing the string using recursion
char temp;
temp = str1[index];
str1[index] = str1[size - index];
str1[size - index] = temp;
if (index == size / 2) 
{
    return;
}
reverse(str1, index + 1, size);
}

1 个答案:

答案 0 :(得分:1)

.flexslider .slides > li {
  background-position: center center;
  background-repeat: no-repeat;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
#slider,
.alink {
  min-height: 300px
}
.alink {
  display: block
}