第一题
a
#include <stdio.h>
#include<string>)
int main(void)
{
char input[100], ch;
int i = 0;
printf("Enter a message:");
while ((ch = getchar()) != '\n')
{
input[i] = ch;
i++;
}
printf("Reversal is:");
for (; i > 0; i--)
{
printf("%c", input[i]);
}
printf("\n");
system("pause");
return 0;
}
b
#include <stdio.h>
#include<string>)
int main(void)
{
char input[100], ch;
int i = 0;
printf("Enter a message:");
while ((ch = getchar()) != '\n')
{
*(input + i) = ch;
i++;
}
printf("%d\n", i);
printf("Reversal is: ");
for (i = i-1; i >= 0; i--)
{
printf("%c", *(input+i));
}
printf("\n");
system("pause");
return 0;
}
第二题
a
#include <stdio.h>
#include<string&g