| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 767 人关注过本帖
标题:我刚写的代码 有砸砖滴米有
只看楼主 加入收藏
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:0 
#include <stdio.h>
#include <string.h>

const int MAX=256;

//应用指针统计一个字符串中有多少个单词
int main()    //不留空 填void
{
    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);    //第几个 应该是1st 2nd 3nd 4nd 这样的
        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.
*/

我这几个值多少分?
2012-12-20 21:49
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
小习小习
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:6
帖 子:1467
专家分:4792
注 册:2012-7-2
收藏
得分:5 
回复 13楼 wp231957
大哥,你要表达什么意思,我生性愚钝

实现自己既定的目标,必须能耐得住寂寞单干。
2012-12-20 22:05
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
于祥
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1047
专家分:4132
注 册:2011-4-24
收藏
得分:5 
mobaimobai

最基础的往往是你最容易忽略的!
2012-12-20 22:12
青春无限
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江苏
等 级:贵宾
威 望:24
帖 子:3451
专家分:19340
注 册:2012-3-31
收藏
得分:0 
看看

学 会看代码…学习写程序…学会搞开发…我的目标!呵呵是不是说大话啊!!一切皆可能
2012-12-20 23:20
快速回复:我刚写的代码 有砸砖滴米有
数据加载中...
 
   



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

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