Need help

Write a program that takes a 3x3 matrix as input and asks for a number entered and prints out its position in the matrix. It displays not found if the number is not in the matrix.
I'll be grateful if someone write me this, i am not that good
Last edited on
Well now's the chance to develop your skills. What part of this are you having difficulty with? Can you display text? Can you obtain a number as input? Do you know what an array is and how to define one?
QuanTFlow (1)
Write a program that takes a 3x3 matrix as input and asks for a number entered and prints out its position in the matrix. It displays not found if the number is not in the matrix.
I'll be grateful if someone write me this, i am not that good


this can help you get started:
1
2
3
4
5
6
7
8
9
10
11
12
int main()
{
	vector<int> m{0,1,2,3,4,5,6,7,8}; //test without entering all that junk
	//for(auto &a : m)  //read it in once happy that it works. 
    //   cin>>a;
   int input{};
    cin >> input;
	auto f = find(m.begin(), m.end(), input);
	if(f != m.end())
	   cout << "found at row " << *f/3 +1 << " col " << *f%3 +1 << '\n';
}
Last edited on
Registered users can post here. Sign in or register to post.