void input(V2 m),函數(shù)是傳值調(diào)用,函數(shù)結(jié)束,你輸入的東西都沒有了,你必須用引用,而不能是這樣定義
改為void input(V2& m)
在矩陣中找一個元素為-1的向量 哪里錯了?
在矩陣中找一個元素為-1的向量 哪里錯了?
#include
#include
#include
#include
#include
using namespace std;
typedef vector V1;
typedef vector V2;
void input(V2 m);
void print(V1 v);
bool find(V2 matrix,V1 v);
int main()
{
V2 matrix;
input(matrix);
V1 vec;
if(find(matrix,vec))
print(vec);
return 0;
}
void input(V2 m)
{
ifstream in("a.txt");
V1 m1;
int n,t;
in>>n;
m.resize(n);
for(string s;getline(in,s);)
{
istringstream s1(s);
for(;s1>>t;)
{
m1.push_back(t);
}
m.push_back(m1);
}
}
bool find(V2 matrix,V1 v)
{
int i,j;
for(i=0;i
#include
#include
#include
#include
#include
using namespace std;
typedef vector V1;
typedef vector V2;
void input(V2 m);
void print(V1 v);
bool find(V2 matrix,V1 v);
int main()
{
V2 matrix;
input(matrix);
V1 vec;
if(find(matrix,vec))
print(vec);
return 0;
}
void input(V2 m)
{
ifstream in("a.txt");
V1 m1;
int n,t;
in>>n;
m.resize(n);
for(string s;getline(in,s);)
{
istringstream s1(s);
for(;s1>>t;)
{
m1.push_back(t);
}
m.push_back(m1);
}
}
bool find(V2 matrix,V1 v)
{
int i,j;
for(i=0;i
其他人氣:915 ℃時間:2020-05-06 01:03:58
優(yōu)質(zhì)解答
我來回答
類似推薦
- 有一矩陣A,找出矩陣中值大于1的元素并將它們重新排列成列向量B
- 用matlab如何實現(xiàn):有一矩陣A,找出矩陣中大于1的元素,并將它們排成列向量B?
- 已知向量C[1,1,-1]是矩陣
- 設(shè)n階矩陣A各行的元素之和均為零,且r(A)=n-1 ,求AX=0( 向量)的解
- 利用列向量 建立一個范得蒙矩陣 ,并利用位于矩陣 的奇數(shù)行偶數(shù)列的元素建立一個新的矩陣 ,
- 判斷一個數(shù)是質(zhì)數(shù)還是合數(shù),要看它什么
- 酬樂天揚州初逢席上見贈中寄希望于未來的哲理詩句是什么
- Whether i go or not,we are the best
- Are ther any books in the bag?Yes,there is__________. A.it B. one C. any D. some
- it`s cool here because wind can blows in ( ) the two windows
- 如圖,是一個幾何體的三視圖,那么這個幾何體是_.
- ”秋處露秋寒霜降”是二十四節(jié)氣歌中的一句,其中第二個”秋”指的是
猜你喜歡
- 1即是兩大洋分界線又是兩大洲分界線的海峽是哪個?
- 2甲數(shù)除以乙數(shù),商是5分之2,甲數(shù)與乙數(shù)的和是21,甲數(shù)是(),乙數(shù)是()
- 3已知f(x)=ax2+bx(a≠0)滿足f(x-1)=f(3-x)且方程f(x)=2x有兩個等根,求f(x)的解析式.
- 4請問有關(guān)趙州橋的傳說有哪些?
- 5關(guān)于interest 的英語改錯
- 6God made the integers; all else is the work of man什么意思
- 7方程0.02分之0.2x-0.2 -0.5分之x+1=3的解是()
- 8多少硫酸和多少氯化鉀高溫后反映出多少硫酸鉀和多少鹽酸.
- 9in my home all the chairs are made of b_____
- 10雷諾實驗中如何正確設(shè)置高位水槽
- 11一只掛鐘的時針長10厘米 急!
- 12they want to buy some fruit .對劃線部分提問(some fr