第一天自学C++啊,大家给我的代码提点意见吧吧。。

来源:百度知道 编辑:UC知道 时间:2024/07/04 02:29:03
第一次写代码啊,写个可以计算油漆罐数的,粉刷各个房间(假设完全一样),要求输入房间和门窗的长宽高来进行计算,大家给我的代码提点意见吧。。(新手啊,自学了一天)。。
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"欢迎使用\n";
int h,w1,l1;
//surface area of the room
cout<<"\n\n房间长,宽,高: \n";
cin>>l1>>w1>>h;
int room1=2*w1*h+2*l1*h+w1*l1;
//area of the window
int w2,l2;
cout<<"窗户长,宽 \n";
cin>>l2>>w2;
int window=w2*l2;
//area of door
int w3,l3;
cout<<"门长,宽 \n";
cin>>l3>>w3;
int door=w3*l3;
//area of each room
int paint=room1-window-door;
//whole house
int n;
cout<<"房间数\n";
cin>>n;
int all=paint*n;
//number of cans
int a;
cout&

int cans=(all/a)+1;
在这一句上提点意见
如果all 刚好能被a整除时,我想就不用加1了。
第一天能有这样的成绩,值得祝贺。

不要老是用\n 用<<endl好看点