码迷,mamicode.com
首页 > 其他好文 > 详细

第六章编程练习6

时间:2017-05-02 22:12:10      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:编程练习   str   code   输入   --   can   span   for   print   

6.编写一个程序把一个单词读入一个字符数组,然后反向打印出这个词。提示:使用strlen()(第
4 章)计算数组中最后一个字符的索引。

#include<stdio.h>
#include<string.h>
int main(void){
    char word[40];
    int i,length;
    printf("请输入一下英文单词:\n");
    scanf("%s",&word);
    length = strlen(word);
    for(i=length-1;i>=0;i--){
        printf("%c",word[i]);
    }
    return 0;
}

 

第六章编程练习6

标签:编程练习   str   code   输入   --   can   span   for   print   

原文地址:http://www.cnblogs.com/zihai/p/6798586.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!