| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 909 人关注过本帖, 1 人收藏
标题:刚接触C 问一个问题
只看楼主 加入收藏
呢喃君
Rank: 2
等 级:论坛游民
帖 子:32
专家分:28
注 册:2012-7-5
收藏
得分:0 
回复 10楼 w995612220
我就说不认识。。。
2012-07-06 12:28
long0042
Rank: 2
等 级:论坛游民
帖 子:38
专家分:50
注 册:2008-3-5
收藏
得分:0 
#include <stdio.h>

#define MAXLINE 1024

int main()
{
    int m_result[MAXLINE];
    int m_current = 0;
    int index = 0;
    int result = 0;
    char buf[128];

    int numA, numB, numTmp;

    while (1)
    {
        gets(buf);
        if (buf[0] == '\0')
            break;

        result = sscanf(buf, "%d %d %d", &numA, &numB, &numTmp);
        if (result != 2)
        {
            printf("输入格式有误,重新输入\n");
            continue ;
        }

        m_result[m_current] = (numA > numB) ? numA : numB;
        m_current++;
        if (m_current >= MAXLINE)
        {
            printf("已经到达了最大行\n");
            break;
        }
    }

    //输出结果
    printf("结果输出如下:\n");
    for (; index < m_current; index++)
    {
        printf("\tNum[%d]: %d\n", index, m_result[index]);
    }

    return 0;
}
配合你们一下, 蛋疼的路过。
2012-07-06 14:58
快速回复:刚接触C 问一个问题
数据加载中...
 
   



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

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