【入门编程题】--1.小玉买文具问题

 

要点在于将整形数据b,也就是角,转换成浮点型 => float c=b;

#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<0||b<0)
        return -1;
	float c=b;
    float totalPrice=a+c/10;
    float unitPrice=1.9;
    int num=(int)(totalPrice/unitPrice);
	cout<<num<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/wxq_1993/article/details/82726409