Muxinfelix 2021-07-14 15:21 采纳率: 50%
浏览 28
已采纳

求该程序哪出错了 ?还是说我的逻辑本身就是错误的?

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;

}

  • 写回答

3条回答 默认 最新

  • qfl_sdu 2021-07-14 15:30
    关注

    你没给变量赋值呢
    代码修改如下:

    #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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 已采纳回答 7月14日
  • 修改了问题 7月14日
  • 创建了问题 7月14日

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services