weixin_45975596
初夏浅梦i
2020-06-04 13:54
采纳率: 100%
浏览 166

请问大佬为什么我添加信息 存不进去数组内 是什么原因

#include"stdafx.h"
using namespace std;

Pt::Pt()
{
int ids[1000]={623501,623502,623503,623504};
string kehus[1000] = { "张三","李四","王二","麻子" };
//客户数组
string sjhs[1000] = {"19124214124","19323574212","18427380461","14214985858"};
//手机号数组
string cjsjs[1000] = {"Fri May 24 01:11:05 2019","Fri May 24 07:31:01 2019","Fri May 24 08:50:49 2019","Fri May 24 09:30:49 2019"};
//订单创建时间
string orderdiver[1000] = { "马男","蔡家正","傅英欣","暂未接单" };
string ztais[1000] = { "是","是","是","否"};
//订单状态
string slsjs[1000]={"Fri May 24 01:15:23 2019","Fri May 24 07:32:05 2019","Fri May 24 08:55:24 2019","暂未受理"};

//受理时间

for (len = 0; len < 1000; len++)
{
    if (ids[len] == 0)
    {
        break;
    }
}



for (int i = 0; i < len; i++)
{
    orders[i].id = ids[i];
    orders[i].kehu = kehus[i];
    orders[i].sjh = sjhs[i];
    orders[i].cjsj = cjsjs[i];
    orders[i].diver = orderdiver[i];
    orders[i].ztai = ztais[i];
    orders[i].slsj = slsjs[i];  

}

}

Pt::~Pt()
{

}

void Pt::allorders() //显示所有订单
{
cout << "已显示所有订单:" << endl;
cout << "订单号\t\t客户名\t\t手机号\t\t生成订单时间\t\t\t司机名\t接受订单状态\t\t受理订单时间" << endl;
for (int i = 0; i < len ; i++)
{
if (orders[i].id==0)
{
break;
}
orders[i].allorders();
}

}

void Pt::buildorders() //显示生成订单
{
cout << "已显示生成订单:" << endl;
cout << "订单号\t\t生成订单时间\t\t\t\t接受订单状态\t\t受理订单时间" << endl;
for (int i = 0; i < len; i++)
{
if (orders[i].kehu == "\0")
{
break;
}
if (orders[i].ztai == "是")
{
continue;
}
orders[i].scorders();
}
}

void Pt::dispatchorders() //显示派遣订单
{
cout << "已显示派遣订单:" << endl;
cout << "订单号\t\t客户名\t\t手机号\t\t生成订单时间\t\t\t接受订单状态\t\t受理订单时间" << endl;
for (int i = 0; i < len; i++)
{
if (orders[i].kehu == "\0")
{
break;
}
if (orders[i].ztai == "否")
{
continue;
}
orders[i].pqorders();
}
}

void Pt::addoneorder()
{
string farexz, farename, bourn, phone, orderxz;
time_t now = time(0);
char* localtime = ctime(&now); // 获取时间
while (1)
{
cout << "请你输入你的姓名:";
cin >> farename;
cout << "请你输入你的目的地:";
cin >> bourn;
cout << "请你输入你的手机号:";
cin >> phone;
cout << "你确定提交该订单吗?是/否";
cin >> orderxz;
if (orderxz == "是" || orderxz == "Y" || orderxz == "y")
{
string localtimenow = localtime;
int idbh = 623500 + len + 1;
orders[len].id = idbh;
orders[len].kehu = farename;
orders[len].diver = "暂未接单";
orders[len].cjsj = localtimenow;
orders[len].ztai = "否";
orders[len].sjh = phone;
orders[len].slsj = "暂未受理";
cout << "提交成功,你的订单号为:" << idbh << "正在等待司机的受理,可在用户模块查看已发布订单查询!" << endl;
for (int i = 0; i < len; i++)
{
if (orders[i].id == 0)
{
break;
}
orders[i].allorders();
}

        break;
    }
    else if (orderxz == "否" || orderxz == "N" || orderxz == "n")
    {
        cout << "订单已取消!" << endl;
        cout << "请问是输入输入错误,需要重新输入还是返回上一级,请选择以下操作:" << endl;
        cout << "-------------------------------------------------------------------------------------" << endl;
        cout << "1、重新输入、2、返回上一级" << endl;
        cout << "-------------------------------------------------------------------------------------" << endl;
        cout << "请输入你的选择:";
        cin >> farexz;
        if (farexz == "1" || farexz == "重新输入")
        {
            continue;
        }
        else if (farexz == "2" || farexz == "返回上一级")
        {
            break;
        }
        else
        {
            cout << "输入错误,请你检查后重新输入!" << endl;
        }
    }
    else
    {
        cout << "输入错误,请你检查后重新输入!" << endl;
        continue;
    }
}

}


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • qq_39554698
    小学狗喵喵叫 2020-06-04 14:09
    已采纳

    i<=len

    for (int i = 0; i <= len; i++)
    {
    if (orders[i].id == 0)
    {
    break;
    }
    orders[i].allorders();
    }
    
    点赞 评论

相关推荐