|
C语言第一题答案
#include<stdio.h>
#include<string.h> /* 包含字符串库函数说明的头文件* /
#include<stdio.h>
void forward_and_backwards(char line_of_char[] ,int index); /* 函数声明* /
void main()
{
char line_of_char[80]; / *定义字符数组* /
int index = 0;
strcpy(line_of_char,"I am a student."); / *字符串拷贝* /
forward_and_backwards(line_of_char,index); / *函数调用* /
}
void forward_and_backwards(char line_of_char[],int index) /*函数定义* /
{
if(line_of_char[index])
{
printf("%c",line_of_char[index]); / *输出字符* /
forward_and_backwards(line_of_char,index+1); / * 递归调用* /
printf("%c",line_of_char[index]); / * 输出字符* /
}
[ 本帖最后由 snowflake 于 2006-5-17 10:51 编辑 ] |
|