
求一个visual C++6.0软件,要可以提示错误位置的那个,
void main()
{
cout<<"This is cargo-charge program!"<<endl;
char owner='$';
float weight=0;
float charge=0;
cout<<"Enter the ower's symbol,please(one character):";
cin>>owner;
cout<<"Enter the cargo's weight,please:";
cin>>weight;
charge=charge+(weight-15)*12; }
cout<<"The ower's symbol is:"<<owner<<endl;
cout<<"The weight is:"<<weight<<endl;
cout<<"The charge is:"<<charge<<endl;
}
你帮我看看这个程序错哪了 展开
这个程序的源代码错了:正确地如下
#include <iostream.h> //头文件的包含格式应该是 #include<header file's name>
void main()
{
cout<<"This is cargo-charge program!"<<endl;
char owner='$';
float weight=0;
float charge=0;
cout<<"Enter the ower's symbol,please(one character):";
cin>>owner;
cout<<"Enter the cargo's weight,please:";
cin>>weight;
charge=charge+(weight-15)*12; //多了一个大括号 意味着main函数到此结束
cout<<"The ower's symbol is:"<<owner<<endl;
cout<<"The weight is:"<<weight<<endl;
cout<<"The charge is:"<<charge<<endl;
}
注意到运行时 我输入jack 输出的却是j 这里onwer最好用一个数组或者string对象 才不会出现刚才的问题

2023-05-10 广告
void main()
{
cout<<"This is cargo-charge program!"<<endl;
char owner='$';
float weight=0;
float charge=0;
cout<<"Enter the ower's symbol,please(one character):";
cin>>owner;
cout<<"Enter the cargo's weight,please:";
cin>>weight;
charge=charge+(weight-15)*12; //此处多了个大括号
cout<<"The ower's symbol is:"<<owner<<endl;
cout<<"The weight is:"<<weight<<endl;
cout<<"The charge is:"<<charge<<endl;
}
可是我这是照着书上写上去的啊
书不是权威的代表,错了也很正常,而且,书有时候是简写的。