矩阵赋值问题
#include
#include
using namespace std;
int tr[10005], tc[10005]; //tr[i]=10记第i行最后一次修改值为10,tc记列。
typedef pair
unordered_map
unordered_map
int n, m,q;
int main()
{
int t,x,y;
cin >> n >> m >> q;
for (int i = 0; i < q; i++)
{
cin >> t >> x >> y;
if (t == 1) {
hang[x] = { t, y };
}
else {
lie[x] = { t, y };
}
}
for (int i = 1; i < n; i++){
for (int j = 1; j < m; j++){
if (hang.count(i) && lie.count(j)) {
int ht = hang[i].first;
int lt = lie[j].first;
if (ht > lt)
{
cout << hang[i].second << " ";
}
else
{
cout << lie[j].second << " ";
}
}
else if (hang.count(i)) cout << hang[i].second << " ";
else cout << lie[j].second << " ";
}
cout << endl;
}
}
C++ 万能头文件 #include
数据流输入/输出:cin>>,cout<<的头文件:#include
算法类函数:sort()…的头文件 #include
各个数学函数:max(),min(),sqrt()…的头文件 #include
字符串操作的头文件 #include 或 #include
结构类:链表,图,队列,迭代器,栈的头文件:
#include #include



