gpt4 book ai didi

c++ - 为什么程序运行时我的第二个循环不执行?

转载 作者:行者123 更新时间:2023-11-28 01:29:58 25 4
gpt4 key购买 nike

<分区>

第一个循环运行完全正常,但第二个循环中的数据未显示。在第一个循环中输入数据后程序结束。我显示错了吗?顺序不对?

#include <iostream>
#include <string>

using namespace std;

struct Empinfo
{
string name;
int pay;
double hours;
double gross_pay;
};
int main()
{
int count;
int index;
const int arraysize = 3;
Empinfo employee[arraysize];
for (count = 0; count < arraysize; count++)
{
cout << "Enter name of employee" << " " << (count + 1) << ":";
cin >> employee[count].name;
cout << "Enter the hourly pay for " << employee[count].name << ": ";
cin >> employee[count].pay;
cout << "Enter how many hours " << employee[count].name << "worked: ";
cin >> employee[count].hours;
cout << endl;

}
for (index = 0; index << arraysize; index++)
{
cout << employee[index].name;
cout << employee[index].pay;
cout << employee[index].hours;
cout << employee[index].gross_pay;

}
system("pause");
return 0;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com