首页 > 解决方案 > 有人可以用 C++ 解释这个数组的输入吗

问题描述

这是我的代码,这个数组的输入是什么?我只是想更多地了解这段代码中的输入

int n;

   float c[10][3];

cout<<“Enter the number of vertices :”;

cin>>n;

        for (i=0;i<n;i++)



{ 

 cout<<“Enter the coordinates of the vertex :”,i+1;.   

   cin>>c[i][0]>>c[i][1];

 c[i][2]=1

  }

标签: c++arrays

解决方案


您正在以这种形式取值

阵列 C

x  y  1
x1 y1 1
.
.
.
x9 y9 1

基本上,您的 i 遍历二维数组的所有行,并分别为第一个和第二个位置获取 2 个输入。第三个位置始终设置为 1。


推荐阅读