在线笔试,实在不懂为何不直接像leetcode 那样,直接给出测试API 参数,接口样例,非要有一步本身从键盘获取输入参数。ios
如下,持续记录吧:数组
(1)从键盘录入多行数据,每行的多个整数做为一个数组形式存储.测试
示例输入:code
1,2,3blog
4,5接口
7,8,9ci
#include<stdio.h> #include<iostream> #include<vector> #include<string> //输入多行数组 int InputMutiint() { std::vector < std::vector<int> > m_array; std::vector<int> tmp; int a; char c; while (std::cin >> a) { tmp.push_back(a); c = getchar(); if (c == '\n') { m_array.push_back(tmp); tmp.clear(); } } return 0; } int main() { InputMutiint(); system("pause"); return 0; }