1. Topic requirements
Two, the code
-
#include <iostream> //标准库 #include <string> //字符串 #include <sstream> //字符串流 #include <vector> //盒子 #include <cmath> //数学库 //命名空间 using namespace std; //切分字符串 vector<string> split(string str,char ch) { //创建字符串盒子 vector<string> results; //将字符串转为字符串流 stringstream ss(str); //创建字符串临时存放点 string temp; //循环切分,并将每一次切分的结果放入盒子 while(getline(ss,temp,ch)) { results.push_back(temp); } //返回结果 return results; } int main() { //创建变量字符串 string str; //从键盘获取字符串 getline(cin,str); //创建字符串盒子 vector<string> results; //切分字符串,并依次放入盒子 results = split(str,' '); //从盒子里拿出字符串1 string str1 = results[0]; //将字符串1转为int int a =stoi(str1); //从盒子里拿出字符串2 string str2 = results[1]; //将字符串2转为int int b =stoi(str2); //计算 int c = a * 10 + b; const int x = 1*10+9; int d = c / x; //输出 cout << d; return 0; }