DHU OJ 二维数组

思路及代码

cpp 复制代码
#include<iostream>
using namespace std;
int main(){
//input 多组
//input M,N int 1<= <=20
//input M 行 N 列 数据
//initialize list
    int M, N;
    while (cin >> M >> N){
        int list[M][N];
        for (int i = 0; i <= M-1; i++){
            for (int j = 0; j <= N-1; j++){
                cin >> list[i][j];
            }
        }
//solution
//遍历 i j output i+1,j+1
        for (int i = 0; i <= M-1; i++){
            for (int j = 0; j <= N-1; j++){
                if (list[i][j] != 0){
                    cout << i+1 << ' ' << j+1 << ' ' << list[i][j] << endl;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

参考:无

收获:无

菜菜,不是教程,做题和学习记录

相关推荐
lingggggaaaa2 分钟前
免杀对抗——C2远控篇&C&C++&DLL注入&过内存核晶&镂空新增&白加黑链&签名程序劫持
c语言·c++·学习·安全·网络安全·免杀对抗
phdsky14 分钟前
【设计模式】建造者模式
c++·设计模式·建造者模式
H_-H15 分钟前
关于const应用与const中的c++陷阱
c++
coderxiaohan21 分钟前
【C++】多态
开发语言·c++
gfdhy31 分钟前
【c++】哈希算法深度解析:实现、核心作用与工业级应用
c语言·开发语言·c++·算法·密码学·哈希算法·哈希
百***06011 小时前
SpringMVC 请求参数接收
前端·javascript·算法
Eiceblue1 小时前
通过 C# 将 HTML 转换为 RTF 富文本格式
开发语言·c#·html
故渊ZY1 小时前
Java 代理模式:从原理到实战的全方位解析
java·开发语言·架构
leon_zeng01 小时前
Qt Modern OpenGL 入门:从零开始绘制彩色图形
开发语言·qt·opengl
会飞的胖达喵1 小时前
Qt CMake 项目构建配置详解
开发语言·qt