c++和python处理读入数据:
c++:
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
vector<string> s;
string temp;
while(cin>>temp)
{
s.push_back(temp);
}
python:
list1 = list(map(str,input().split()))
如果是输入两个字符串,想要将其分割,可以这么写:
n, m = [int(x) for x in input().split()]
读入字符串:
s = list(map(str,input().split(’ ‘)))
打印:print(res,end=’ ')
input()和input().split()的区别:
s = input()
print(s)
输入:abc123 def456
输出:abc123 def456
s = input().split()
print(s)
输入:abc123 def456
输出:['abc123', 'def456']