| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 767 人关注过本帖
标题:我刚写的代码 有砸砖滴米有
取消只看楼主 加入收藏
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
结帖率:99.76%
收藏
已结贴  问题点数:40 回复次数:6 
我刚写的代码 有砸砖滴米有
程序代码:
#include <stdio.h>
#include <string.h>

const int MAX=256;

//应用指针统计一个字符串中有多少个单词
int main()
{
    char* nums[]={ "one" , "two"   , "tree"  , "four" , "five"\
                 , "six" , "seven" , "eight" , "nine" , "ten" };
    char word[MAX]={'\0'};
    char* test="This is a test number of words in the sentences.";
    char* p1=test;
    char* p2=test;
    int len=0;
    int index=0;
    while(1)
    {
        if (*(p2+1)!=0x20)
        {
            p2++;
            if (*p2!='\0') continue;
        }
        p2++;
        len=(int)(p2-p1);
        strncpy(word,p1,len);
        word[len]='\0';
        printf("the %5s word is : %s\n",nums[index],word);
        p2++;
        p1=p2;
        index++;
        if (*p2=='\0') break;
    }
    return 0;

}

/*
  样例输出:
    the   one word is : This
    the   two word is : is
    the  tree word is : a
    the  four word is : test
    the  five word is : number
    the   six word is : of
    the seven word is : words
    the eight word is : in
    the  nine word is : the
    the   ten word is : sentences.
*/
搜索更多相关主题的帖子: test include number 字符串 
2012-12-20 20:32
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
楼上的 和楼上的楼上都不咋地道

这么2行浅显的代码  就大牛、大作  ???

DO IT YOURSELF !
2012-12-20 21:06
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
以下是引用yuccn在2012-12-20 21:25:39的发言:

40分给我吧
说说代码需要改进的地方  单独开个贴 也无所谓啊

DO IT YOURSELF !
2012-12-20 21:28
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
以下是引用qq839431011在2012-12-20 21:36:50的发言:

来篇大作、大牛呗,让大伙开开眼界呀  
多大作 算大作啊   我连单链表都不会呢

DO IT YOURSELF !
2012-12-20 21:37
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
那个英文待测试句子 是我google翻译过来的 我自己不会
那个 第N 的 我也不会  刚开始时 用的是 数字呢

DO IT YOURSELF !
2012-12-20 21:53
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
回复11楼z版

你这几个问题 都不是问题

第一个,貌似书上都没有void
第二、三个  貌似和c没关系

DO IT YOURSELF !
2012-12-20 21:54
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
以下是引用小习小习在2012-12-20 22:05:29的发言:

大哥,你要表达什么意思,我生性愚钝
看11楼啊  我是回复11楼z版的

DO IT YOURSELF !
2012-12-20 22:06
快速回复:我刚写的代码 有砸砖滴米有
数据加载中...
 
   



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

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