标题:[求助]国外大学作业
取消只看楼主
baiwhut
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-9-28
 问题点数:0 回复次数:0 
[求助]国外大学作业
如何把以下程序的template classes去掉,1.改成用generic classes编写的c++程序,2.改成用obstract classes编写的c++程序.

// Generic Floyd-Warshall
// Demonstrates templates


#include <iostream.h>
template<class Value, Value initial,
Value (*plus)(Value,Value),
Value (*mult)(Value,Value)>
void floydWarshall(Value *v, int n) {
for(int k=0; k<n; k++)
v[n*k+k]=initial;
for(int k=0; k<n; k++)
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
v[n*i+j]=plus(v[n*i+j], mult(v[n*i+k],v[n*k+j]) );
}
bool plus (bool a, bool b) { return a || b; }
bool mult (bool a, bool b) { return a && b; }
int main(int argc, char **argv) {
int n;
cin >> n;
bool *test=new bool(n*n);
for(int i=0; i<n*n; i++)
cin >> test[i];
floydWarshall<bool,true,plus,mult>(test,n);
return 0;
}
搜索更多相关主题的帖子: 作业 大学 国外 
2005-09-28 00:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-28847-1-1.html




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

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