根据double dist[MAX_OBJECT_TYPE][MAX_OBJECT_TYPE] = { {0.2, 0.3, 0.4, 0.5, 0.6, 1}, {0.3, 0.2, 0.3, 0.4, 0.5, 0.6}, {0.4, 0.3, 0.2, 0.3, 0.4, 0.5}, {0.5, 0.4, 0.3, 0.2, 0.3, 0.4}, {0.6, 0.5, 0.3, 0.4, 0.2, 0.3}, {1 , 0.6, 0.5, 0.4, 0.3, 0.2} };结合不同横纵坐标读取表格数值并输出
时间: 2023-08-19 07:28:36 浏览: 83
好的,您可以使用以下代码来读取表格数值并输出。
```c++
#include <iostream>
using namespace std;
const int MAX_OBJECT_TYPE = 6;
int main() {
double dist[MAX_OBJECT_TYPE][MAX_OBJECT_TYPE] = {
{0.2, 0.3, 0.4, 0.5, 0.6, 1},
{0.3, 0.2, 0.3, 0.4, 0.5, 0.6},
{0.4, 0.3, 0.2, 0.3, 0.4, 0.5},
{0.5, 0.4, 0.3, 0.2, 0.3, 0.4},
{0.6, 0.5, 0.3, 0.4, 0.2, 0.3},
{1, 0.6, 0.5, 0.4, 0.3, 0.2}
};
int x, y;
cout << "请输入横坐标和纵坐标(坐标范围为0~5):" << endl;
cin >> x >> y;
if (x < 0 || x >= MAX_OBJECT_TYPE || y < 0 || y >= MAX_OBJECT_TYPE) {
cout << "坐标不合法!" << endl;
return 0;
}
cout << "表格数值为:" << dist[x][y] << endl;
return 0;
}
```
您可以根据需要修改输入的坐标范围和输出的信息。
阅读全文
相关推荐
















