#include <vector> #include <iostream> using namespace std; int main() { int k; cin>>k; vector<vector<int> > arr; vector<int> a; int tmp; while(cin>>tmp){ int i=0; if(arr.size()<i+1) arr.push_back(a); arr[i].push_back(tmp); while(cin.get()!=‘\n‘){ cin>>tmp; i++; if(arr.size()<i/k+1) arr.push_back(a); arr[i/k].push_back(tmp); } } for(int i=0;i<arr.size();i++){ for(int j=0;j<arr[i].size();j++){ if(i==arr.size()-1 && j==arr[i].size()-1){ cout<<arr[i][j]<<endl; }else{ cout<<arr[i][j]<<","; } } } return 0; } /* 3 1,2,3,4,5,6,7 8,9,5,6,7 */
原文地址:https://www.cnblogs.com/joelwang/p/10651592.html
时间: 2024-10-08 01:42:22