| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 573 人关注过本帖
标题:你敢挑战么?某高校入会题目
取消只看楼主 加入收藏
abc594986308
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:168
专家分:116
注 册:2013-3-18
结帖率:82.93%
收藏
已结贴  问题点数:10 回复次数:2 
你敢挑战么?某高校入会题目
编写函数reverse(s),将字符串s中的字符顺序颠倒过来。使用该函数编写一个程序,每次颠倒一个输入行中的字符顺序。
#include <stdio.h>
   #define MAXLINE 1000   /* maximum input line length */
  int getline(char line[], int maxline);
   void copy(char to[], char from[]);
   /* print the longest input line */
   main()
   {
       int len;            /* current line length */
       int max;            /* maximum length seen so far */
       char line[MAXLINE];    /* current input line */
       char longest[MAXLINE]; /* longest line saved here */
       max = 0;
       while ((len = getline(line, MAXLINE)) > 0)
           if (len > max) {
               max = len;
               copy(longest, line);
           }
       if (max > 0)  /* there was a line */
           printf("%s", longest);
       return 0;
   }
   /* getline:  read a line into s, return length  */
   int getline(char s[],int lim)
   {
       int c, i;
       for (i=0; i < lim-1 && (c=getchar())!=EOF && c!='\n'; ++i)
           s[i] = c;
       if (c == '\n') {
           s[i] = c;
           ++i;
       }
       s[i] = '\0';
       return i;
   }
   /* copy:  copy 'from' into 'to'; assume to is big enough */
   void copy(char to[], char from[])
   {
       int i;
       i = 0;
       while ((to[i] = from[i]) != '\0')
           ++i;
   }
搜索更多相关主题的帖子: current include 字符串 
2013-06-22 12:43
abc594986308
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:168
专家分:116
注 册:2013-3-18
收藏
得分:0 
回复 3楼 韶志
我的意思是你运用下面类似的代码编写,有串流的。。这个不当之处请见谅。。。
2013-06-22 20:31
abc594986308
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:168
专家分:116
注 册:2013-3-18
收藏
得分:0 
回复 4楼 蚕头燕尾
也不是很难哈,但是就是不会用串流。。。
2013-06-22 20:32
快速回复:你敢挑战么?某高校入会题目
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015580 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved