C++ 如何修复此[错误]无法转换';浮动[6]和#x27;浮动

C++ 如何修复此[错误]无法转换';浮动[6]和#x27;浮动,c++,arrays,if-statement,C++,Arrays,If Statement,下面是我的代码,我有一个错误。([错误]无法在分配中将“float[6]”转换为float。) 我不知道该怎么做,也不知道该如何盈利。。。 我的目标是把最高的费用、最高的利润和最低的利润放在下面。但我有这样的错误。 #包括 #包括 使用名称空间std; int main(){ 整月[]={1,2,3,4,5,6}; 浮动利润; 弦月名; 浮动销售[6]={1000、1500、2500、5000、4000、1800}; 浮动费用[6]={500、250、100、1000、200、800}; 浮动

下面是我的代码,我有一个错误。([错误]无法在分配中将“float[6]”转换为float。) 我不知道该怎么做,也不知道该如何盈利。。。 我的目标是把最高的费用、最高的利润和最低的利润放在下面。但我有这样的错误。

#包括
#包括
使用名称空间std;
int main(){
整月[]={1,2,3,4,5,6};
浮动利润;
弦月名;
浮动销售[6]={1000、1500、2500、5000、4000、1800};
浮动费用[6]={500、250、100、1000、200、800};
浮动totalex=0,totalsale=0,totalprofit;
float highSales=0,highExp=0,highProf=0,lowProf=0;
字符串highMonth=“”;

cout
highExp=expenses;
在这一行中,highExp是一个浮点,而expenses是一个
float[6]
,因此您试图将一个浮点数组分配给一个无效的浮点


另外,
for(int i=0;i Hint:compiler会告诉您问题发生在哪一行。例如,告诉我错误在第35行。我查看了那里,发现输入错误:
highExp=expenses;
应该是
highExp=expenses[i]
非常感谢您现在我在对齐时遇到了麻烦一步一个脚印,查找您难以理解的内容。在本节中:我不确定您的确切意思,但std::setw函数可能很有用,可以为利润值设置固定的字符串宽度我现在包括一张图片,二月部分与其他部分完全不同
#include <iostream>
#include <string>
using namespace std;
int main(){
int month[] = {1,2,3,4,5,6};
float profit;
string monthName;
float sales[6] = {1000, 1500, 2500, 5000, 4000, 1800};
float expenses[6] = {500, 250, 100, 1000, 200, 800};
float totalex=0,totalsale=0,totalprofit;


float highSales=0, highExp=0, highProf=0, lowProf=0;
string highMonth="";

cout << "Company Sales and Expenses For 2020" << endl;  

for (int i=0; i <=6; i++ ) {
    profit = sales[i]-expenses[i];
    totalprofit+=profit;
    totalsale+=sales[i];
    totalex+=expenses[i];
    switch(month[i]) {
        case 1:  monthName="January"; break;
        case 2:  monthName="February"; break;
        case 3:  monthName="March"; break;
        case 4:  monthName="April"; break;
        case 5:  monthName="May"; break;
        case 6:  monthName="June"; break;
        
    }
    if(sales[i]>highSales) {
          highSales = sales[i];
          highMonth = monthName;
          highExp = expenses;
          highProf = profit;
          lowProf = profit;
    }
    
    cout <<"\n\n" << monthName<<"\t\t"<<sales[i]<<"\t\t"<<expenses[i]<<"\t\t\t"<<profit;
   }


cout << "\nSummary : " << endl;
   cout << "\tTotal Sales : " << totalsale << endl;
   cout << "\tTotal Expenses : " << totalex << endl;
   cout << "\tTotal Profit : " << totalprofit << endl;

   cout << "\tHighest Sales : " << highSales << "\tMonth of " << highMonth << endl;
   cout << "\tHighest Expenses : " << highExp << "\tMonth of " << highMonth << endl;
   cout << "\tHighest Profit : " << highProf << "\tMonth of " << highMonth << endl;
   cout << "\tLowest Profit : " << lowProf   << "\tMonth of "  << highMonth << endl;

   cout << "\nProgrammed by: ";
          
    return 0;
}