#include <iostream>
using namespace std;
void matrice(int n){
int D[n][n];
cout<<"Input the number of the elements "<<endl;
cin>>n;
cout<<"Input the elements :";
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>D[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(int min=0>D[i-1][j-1]){
D[i-1][j-1]=min;
}
}
}
cout<<" The smallest element is : "<< min<<"and it is the"<< i <<" element ." ;
}
int main(){
int i, min ,j,n;
int n1;
cout<<"Decide: "<<endl;
cout<<"Matrice[1]"<<"\t"<<"Vekcor[2]"<<endl;
cin>>n1;
if(n1==1){
matrice(n);
}
else if(n1==2){
}
}
问题出在cout的第22行,它给出了以下消息:C:\ Users \ use \ Documents \ Dev C ++ \ void_vektor.cpp | 22 |错误:'operator <
主要问题是您在for循环中声明了min
,它将在循环退出时超出范围。