c++编程练习2
来源:互联网 发布:origin pro for mac 编辑:程序博客网 时间:2024/04/26 22:00
1. 给定一个带权(非负)有向图,打印输出从节点S到节点T的最短路径(要求打印最短路径长度和具体的路径)
int main() {
Graph<Node> G; // Graph is a class with template
G.build(data.txt); // build the graph
Path<Node> path; //Path is a class with template
path = G.shortest_path(S, T);
cout << path;
return 0;
}
One solution for the exercise is given by Sonia in "C++编程练习3".
2. Given n rectangles, each of them is represented by (length, wide), please order the n rectangles by length using insertion sort algorithm.
class Rectangle {
private:
int length;
int wide;
public:
//...
}
class List {
private:
int count; // the current number of rectangles in the list
Rectangle * head; // the head of the List
public:
//...
}
3. Given n rectangles, each of them is represented by (length, wide), please order the n rectangles by length using insertion sort algorithm.
struct Rectangle {
int length;
int wide;
//...
}
struct List {
int count; // the current number of rectangles in the list
struct Rectangle * head; // the head of the List
//...
}
4. Given 3 rectangles, each of them is represented by (length, wide), please order the n rectangles by length using insertion sort algorithm.
struct Rectangle {
int length;
int wide;
//...
}
- C语言编程(练习2:函数 )
- pointers on c 编程练习 6-2
- c编程练习
- C编程小练习
- C语言编程练习
- C语言编程小练习
- C语言编程练习(二)
- 学习c编程练习1
- C和指针-编程练习
- C语言编程练习一
- C语言编程练习二
- C语言编程练习随笔
- [C练习]编程实现strstr
- C语言函数编程练习
- 【essential c++】模板函数编程练习2_5
- C语言编程(练习2:循环,三大循环结构 )
- C语言编程(练习2:分支和跳转 )
- C语言编程(练习2:字符输入和输出 )
- Android JNI 使用的数据结构JNINativeMethod详解
- C++ Windows Hook 消息钩子 详解
- 经典c编程
- C/C++中如何使用Luajit脚本
- javascript中encodeURI和decodeURI方法
- c++编程练习2
- CTS感受
- world wind 配置文件的几点说明
- 怎样安装注册金蝶软件
- Android HttpClient接口
- (译)如何使用cocos2d1.0来给sprite添加Mask(遮罩)
- Crontab
- top、postop、scrolltop、scrollHeight、offsetHeight
- 金蝶软件K3和金蝶软件KIS有什么不同?K3和其他财务软件的最大不同是什么?