博文

c/c++基礎習題解決(1)--找出第3名学生的成绩(2007-07-27 21:19:00)

摘要:ACM大学刚考完大学英语4级考试,想知道全校第3名学生的成绩是多少?
如果最高分有好多个学生,则相同成绩的学生都算第一名;同理,如果第二高分的有多个学生,都算第二名。
当然这是简单题,请你快速编一个程序找到第3名的成绩。

输入:输入有多组,每组有2行,第一行是学生人数N(1<=N<10000),第二行有N个整数,分别表示每个学生的成绩(0到1e9)。当输入的N为0的时候结束程序。

输出:对于每组输入,输出只有一行,即第3名学生的成绩,如果找不到,则输出No such score !

Sample input:
10
90 84 90 60 70 65 73 85 98 98
5
90 90 89 90 90
0

Sample output:
85
No such score !

难度:for beginner
Time limit: 50ms   Memory: 200K
                                                   --試題來源:飛燕之家c/c++學習論壇   解決代碼: #include <iostream>
#include <assert.h>
#include <memory.h>
using namespace std; //define some constants
const int  MAXNUM     &......

阅读全文(2756) | 评论:0

c++中链表操作(2006-08-03 22:22:00)

摘要:http://www.angeltears.cn/dispbbs.asp?boardID=20&ID=130&page=1......

阅读全文(2643) | 评论:3

[原创](C++)循环链表操作及应用(约瑟夫环问题)(2006-08-03 22:21:00)

摘要:http://www.angeltears.cn/dispbbs.asp?boardID=20&ID=928&page=1......

阅读全文(3409) | 评论:4

[原创]c++排序算法实现(2006-08-03 22:20:00)

摘要:http://www.angeltears.cn/dispbbs.asp?boardID=20&ID=929&page=1......

阅读全文(2370) | 评论:3

[原创]c++模板实现带头结点的链表操作(2006-08-03 22:19:00)

摘要:http://www.angeltears.cn/dispbbs.asp?boardID=20&ID=930&page=1......

阅读全文(2547) | 评论:2

[原创](C++模板)多项式运算(加减乘法)(2006-08-03 22:18:00)

摘要:http://www.angeltears.cn/dispbbs.asp?boardID=20&ID=931&page=1......

阅读全文(3146) | 评论:14

[原创](C++)稀疏距阵操作(2006-08-03 22:17:00)

摘要:http://www.angeltears.cn/dispbbs.asp?boardID=20&ID=932&page=1......

阅读全文(2449) | 评论:4

[原创]链表实现多项式加法(数据封装和重载)(2006-08-03 22:14:00)

摘要:http://www.angeltears.cn/dispbbs.asp?boardID=20&ID=972&page=1......

阅读全文(2748) | 评论:5

面向对象c++数据结构描述==>>线性表的操作(类模版的应用)(2005-09-23 23:46:00)

摘要:#ifndef list_H
#define list_H
#include"List_Node.h"
template<class T>
class list:public listnode<T>
{
 private:
  listnode<T>* head;
  listnode<T>* tail;
  listnode<T>* current;
  static int size;
 public:
  list(T b,listnode<T>* ptrnext):listnode<T>(b,ptrnext)
  {
   head=tail=current=0;
  }
  ~list();
  bool insertnode(T num1,int);
  bool deletenode(T num2);
  int searchnode(T num3);
  void showlist();
  int getsize();
  int menu1();
};
template <class T>
int list<T>::size=0;
#endif
#ifndef List_Node_H
#define List_Node_H
template <class T>
class listnode
{
private:
 T value;
 listnode<T>* next;
public:
 listnode(T a=0,listnode<T>......

阅读全文(5702) | 评论:3

面向对象c++数据结构==>>数组(2005-09-06 22:15:00)

摘要:#ifndef MGR
#define MGR
class arraymgr
{
    int total_elements,max_elements;
    int * thearray;
public:
    arraymgr(int);
    ~arraymgr();
    bool addelement(int);
    bool getelement(int,int &);
    bool deleteelement(int);
    bool findelement(int,int &);
    void showelements();
    int getsize();
};
#endif
#ifndef a
#define a
#include"mgr.h"
#include<iostream>
using namespace std;
arraymgr::arraymgr(int num)
{
    max_elements=num;
    total_elements=0;
    thearray=new int [max_elements];
}
arraymgr::~arraymgr()
{
    delete [] thearray;
}
bool arraymgr......

阅读全文(3929) | 评论:0