struct client_BankRakyat
{
string name_clien;
string name_garentor;
string level_of_study;
int duration_loan;
float total_of_loan;
};
参考上面的struct定义,你需要做一个YBR客户端的struct声明,并用C++编写一个完整的程序来输入和输出100个YBR客户端的数据。
#include
using namespace std;
#include
struct client_BankRakyat
{
string name_clien;
string name_garentor;
string level_of_study;
int duration_loan;
float total_of_loan;
};
int main()
{
string name_clien;
string name_garentor;
string level_of_study;
int duration_loan;
float total_of_loan;
for (int i = 0; i < 100; i++)
{
cout <<" name: _clien"<< name_clien
<< " name: _garentor" << name_garentor
<< " level: _of_study" << level_of_study
<< " duration: _loan "<< duration_loan
<<" total: _of_loan" << total_of_loan << endl;
}
system(" pause ");
return 0;
}
你没给变量赋值呢
代码修改如下:
#include <iostream>
#include <string>
using namespace std;
struct client_BankRakyat
{
string name_clien;
string name_garentor;
string level_of_study;
int duration_loan;
float total_of_loan;
};
int main()
{
struct client_BankRakyat st[100]; //定义一个结构体数组
int i;
//赋值
for (i=0;i<5;i++) //先写5个吧,100个累死
{
cout << "请输入name_clien:";
cin >> st[i].name_clien;
cout << "请输入name_garentor:";
cin >> st[i].name_garentor;
cout << "请输入level_of_study:";
cin >> st[i].level_of_study;
cout << "请输入duration_loan:";
cin >> st[i].duration_loan;
cout << "请输入total_of_loan:";
cin >> st[i].total_of_loan;
}
//显示
for (i = 0; i < 5; i++)
{
cout <<" name_clien:"<< st[i].name_clien
<< " name_garentor:" << st[i].name_garentor
<< " level_of_study:" << st[i].level_of_study
<< " duration_loan: "<< st[i].duration_loan
<<" total_of_loan:" << st[i].total_of_loan << endl;
}
system(" pause ");
return 0;
}
供参考:
#include<iostream>
#include<string>
using namespace std;
struct client_BankRakyat
{
string name_clien;
string name_garentor;
string level_of_study;
int duration_loan;
float total_of_loan;
};
int main()
{
struct client_BankRakyat YBR[100];
for(int i=0;i<100;i++)
{
cin>>YBR[i].name_clien>>YBR[i].name_garentor
>>YBR[i].level_of_study>>YBR[i].duration_loan
>>YBR[i].total_of_loan;
}
for (int i = 0; i < 100; i++)
{
cout <<"name_clien: "<< YBR[i].name_clien<<endl;
cout <<"name_garentor: " << YBR[i].name_garentor<<endl;
cout <<"level_of_study:" << YBR[i].level_of_study<<endl;
cout <<"duration_loan: "<< YBR[i].total_of_loan<<endl;
cout <<"total_of_loan: " << YBR[i].total_of_loan << endl;
}
system(" pause ");
return 0;
}
#include
using namespace std;
#include
struct client_BankRakyat
{
string name_clien;
iostream 为什么不显示啊