| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1524 人关注过本帖
标题:<求助>请帮把这几道题编程
只看楼主 加入收藏
逃离色彩
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-12-10
收藏
得分:0 
我这只是一科,还有操作系统了,更恶心.minix的..恶心死我了.
2008-05-14 11:43
guojun923
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-5-14
收藏
得分:0 
上面的那个求最大的有错误啊
上面的那个求最大的有错误啊
2008-05-14 13:20
zjl138
Rank: 1
等 级:新手上路
威 望:1
帖 子:788
专家分:0
注 册:2007-11-12
收藏
得分:0 
数组初始化错误。
楼上可以自已改好,再发上来给大家看一下。

i like linux...
2008-05-14 13:40
daocaorenhe
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-4-22
收藏
得分:0 
回复 1# 的帖子第一题
#include <iostream.h>

void main()
{
    int i, temp, a[7] = {0};
    temp = a[0];
    
    cout<<"please input sever number:"<<endl;
    for (i = 0; i < 7; i++)
    {
        cin>>a[i];
        if (temp < a[i])
            temp = a[i];
    }
    cout<<"the max number is:"<<temp<<endl;

}
2008-05-14 17:37
daocaorenhe
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-4-22
收藏
得分:0 
回复 1# 的帖子第一题
#include <iostream.h>

void main()
{
    int i, temp, a[7] = {0};
    temp = a[0];
    
    cout<<"please input sever number:"<<endl;
    for (i = 0; i < 7; i++)
    {
        cin>>a[i];
        if (temp < a[i])
            temp = a[i];
    }
    cout<<"the max number is:"<<temp<<endl;

}
2008-05-14 17:39
daocaorenhe
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-4-22
收藏
得分:0 
the second
#include <iostream.h>

class num
{
 public:
    int var();

 private:
    static int sum;
};
int num::sum = 0;

int num::var()
{
  for(int i = 0; i <= 100; i++)
  {
    if(i % 2==0)
        sum += i;
  }
  return sum;
}

int main()
{
  num a;
  cout<<"1--100的偶数之和:"<<a.var()<<endl;
  return 0;
}
2008-05-14 19:38
daocaorenhe
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-4-22
收藏
得分:0 
the third
#include <iostream.h>

class box
{
public:
    box(float i, float j, float k);
    ~box();
  float    bulk();
  float    area();
private:
    float length;
    float width;
    float height;
};

box::box(float i, float j, float k)
{
    length = i;
    width = j;
    height = k;
}

box::~box()
{
}

float box::bulk()
{
    float bulk;
    bulk = length*width*height;
    return bulk;
}

float box::area()
{
    float area;
    area = 2*(length*width + width*height + length*height);
    return area;
}

void main()
{
    box BOX(1,2,3);
    cout<<"the bulk is:"<<BOX.bulk()<<endl;
    cout<<"the area is:"<<BOX.area()<<endl;
}
2008-05-14 19:39
daocaorenhe
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-4-22
收藏
得分:0 
第四题看不懂什么意思,所以直接第五题
#include <iostream.h>
#include <string.h>
class time
{
public:
    time();
    ~time();
  void    nextime();
  void    display();
private:
    int hour;
    int minute;
    int second;
};

time::time()
{
    hour = 0;
    minute = 0;
    second = 0;
}

time::~time()
{
}

void time::nextime()
{
    second += 1;
        if (second == 60)
        {
            minute += 1;
            second = 0;
        }
        if (minute == 60)
        {    
            hour += 1;
            minute = 0;
        }
        if (hour == 24)
            hour = 0;
}

void time::display()
{
    
    cout<<hour<<"时 "<<minute<<"分 "<<second<<"秒"<<endl;
    
}

void main()
{
    time TIME;
    TIME.display();
while(1)
{
    char a;
    cin>>a;
    if (a != 'q')
    {
        TIME.nextime();
        TIME.display();
    }
    else
        break;    
}
}
2008-05-14 19:40
快速回复:<求助>请帮把这几道题编程
数据加载中...
 
   



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

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