⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_a002.cpp

📁 非常著名的曲线拟合程序
💻 CPP
字号:
// This is -*- C++ -*-// $Id: test_A002.cpp,v 1.2 1999/07/20 08:34:29 alstrup Exp $#include <config.h>#include <iostream>#include <math.h>#include <zdouble.h>using namespace std;const char* encoded[] = {  "???????????",  "??????o~??B",  "??????o~??J",  "mEZox`H?HNS",  "qR{eU[G?ENf",  0};double decoded[] = {  0,  1,  -1,  3.14159,  12345.6789012345,  0};main(){  cout.precision(16);  cout << "Checking fixed example set:" << endl;  int i=0;  while (encoded[i]) {    cout << encoded[i] << " =?= " << decoded[i] << " ";    double y = decode_double(string(encoded[i]));    string s = encode_double(decoded[i]);    if (decoded[i] == y && string(encoded[i]) == s)      cout << "ok";    else      cout << "failed";    cout << endl;    ++i;  }  cout << endl << "Checking generated examples:" << endl;  for(int i=-100; i<100; ++i) {    double x = (sin(i) + 1e-4) * exp(i / 3.333);    string s = encode_double(x);    double xx = decode_double(s);    cout << s << " =?= " << x << " ";    if (x == xx)      cout << "ok";    else      cout << "failed";    cout << endl;  }  return 0;   }// $Id: test_A002.cpp,v 1.2 1999/07/20 08:34:29 alstrup Exp $

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -