洛谷题库—入门1—顺序结构—P3954 [NOIP2017 普及组] 成绩

 一、题目要求洛谷题库—入门1—顺序结构—P3954 [NOIP2017 普及组] 成绩_第1张图片

 

二、代码


  1.  
    #include  //标准库
    #include    //字符串
    #include   //字符串流
    #include    //盒子
    #include     //数学库
    
    //命名空间
    using namespace std;
    //切分字符串
    vector split(string str,char ch)
    {
    	//创建字符串盒子
    	vector 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 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;
    	    
    }
    	

你可能感兴趣的:(C++学习-洛谷题库,c++)