Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
149445 Kevin 【数组】稀疏矩阵(例题) C++ Accepted 175 MS 4204 KB 403 2026-03-13 14:52:48

Tests(4/4):


Code:

#include<bits/stdc++.h> using namespace std; int a[1005][1005],b[1005][5]; int main() { int n,m,x=1; cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>a[i][j]; if(a[i][j]!=0){ b[x][1]=i; b[x][2]=j; b[x][3]=a[i][j]; x++; } } } for(int i=1;i<x;i++){ for(int j=1;j<=3;j++){ cout<<b[i][j]<<" "; } cout<<endl; } return 0; }