本文整理汇总了C++中DVector::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ DVector::getLength方法的具体用法?C++ DVector::getLength怎么用?C++ DVector::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DVector
的用法示例。
在下文中一共展示了DVector::getLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
cout << "/----------------------------\\" << endl;
cout << "| |" << endl;
cout << "| The Project has just begun |" << endl;
cout << "| |" << endl;
cout << "\\----------------------------/" << endl;
// Tests mit einem Vector
DVector<double> dvect;
dvect.append(5.4321);
dvect.append(3.1415);
dvect.append(9.81);
dvect.append(2.7);
dvect.append(123456);
try{
dvect.add(123, 55);
} catch (DException &e) {
cout << e.what() << endl;
}
for(unsigned int i=0; i<dvect.getLength(); ++i){
cout << "dvect[" << i << "] = " << dvect.getData(i) << endl;
}
cout << "\nThe list contains " << dvect.getLength() << " entries." << endl;
cout << "add '1' at position '1'." << endl;
dvect.add(1, 1);
for(unsigned int i=0; i<dvect.getLength(); ++i){
cout << "dvect[" << i << "] = " << dvect.getData(i) << endl;
}
cout << "\nThe list contains " << dvect.getLength() << " entries." << endl;
cout << "add '4' at position '4'." << endl;
dvect.add(4, 4);
for(unsigned int i=0; i<dvect.getLength(); ++i){
cout << "dvect[" << i << "] = " << dvect.getData(i) << endl;
}
cout << "\nThe list contains " << dvect.getLength() << " entries." << endl;
cout << "add '0' at position '0'." << endl;
dvect.add(0, 0);
for(unsigned int i=0; i<dvect.getLength(); ++i){
cout << "dvect[" << i << "] = " << dvect.getData(i) << endl;
}
cout << "\nThe list contains " << dvect.getLength() << " entries." << endl;
cout << "add '8' at position '8'." << endl;
dvect.add(8, 8);
for(unsigned int i=0; i<dvect.getLength(); ++i){
cout << "dvect[" << i << "] = " << dvect.getData(i) << endl;
}
cout << "\nThe list contains " << dvect.getLength() << " entries." << endl;
cout << "add '8' at position '8'." << endl;
dvect.add(8, 8);
for(unsigned int i=0; i<dvect.getLength(); ++i){
cout << "dvect[" << i << "] = " << dvect.getData(i) << endl;
}
cout << "\nThe list contains " << dvect.getLength() << " entries." << endl;
cout << "add '1' at position '1'." << endl;
dvect.add(1, 1);
for(unsigned int i=0; i<dvect.getLength(); ++i){
cout << "dvect[" << i << "] = " << dvect.getData(i) << endl;
}
return a.exec();
}