本文介绍了为什么我不能在这种情况下通过值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include< iostream>


使用命名空间std;


int main(void){


union任务{

int TaskNumber;

浮动长度;

};


//变量

static int TaskNumber = 0;

const int SIZE = 100;

int NumberOfTask = 0;

任务时间表[SIZE];

cout<<"有多少个任务?;

cin>> NumberOfTask;


//要求输入

cout<<"请输入任务的长度(分钟):"<< endl;

for(int i = 0; i< NumberOfTask; i ++)

{

int length = 0;


//分配任务编号

TaskNumber ++;

cout<< TaskNumber<< endl;

Schedule [i] .TaskNumber = TaskNumber;

cout<< Schedule [i] .TaskNumber<< endl;


//请求每个任务的长度

cout<<"" Number"<< Schedule [i] .TaskNumber<<"任务需要:" ;;

cin>>长度; //注意:确保240以内的时间长度
Schedule [i] .Length =长度;

cout<< TaskNumber << TaskNumber<< endl;

cout<< Schedule [i] .TaskNumber << Schedule [i] .TaskNumber<<结束;


}


//显示用户的输入

for(int i = 0; i< NumberOfTask; i ++)

{

cout<<"" Number"<< Schedule [i] .TaskNumber<<"任务需要

<< Schedule [i] .Length<<<"分钟"。<<结束;

}


//按任务长度顺序排列


返回0;

}

// ---------------------------------- ----------------- //

如何解决这个问题?

请帮助,谢谢:)

#include<iostream>

using namespace std;

int main(void){

union Task{
int TaskNumber;
float Length;
};

// variables
static int TaskNumber= 0;
const int SIZE = 100;
int NumberOfTask = 0;
Task Schedule[SIZE];
cout<<"How many tasks are there?";
cin >>NumberOfTask;

// ask for input
cout<<"Please enter the length of tasks (mins):"<<endl;
for(int i=0; i<NumberOfTask; i++)
{
int Length = 0;

// Assign task number
TaskNumber++;
cout << TaskNumber << endl;
Schedule[i].TaskNumber= TaskNumber;
cout << Schedule[i].TaskNumber << endl;

// request for the length of each task
cout<<"Number "<< Schedule[i].TaskNumber <<" task takes :";
cin >>Length; // note: ensure length of time within 240
Schedule[i].Length= Length;
cout << "TaskNumber " << TaskNumber << endl;
cout << "Schedule[i].TaskNumber " << Schedule[i].TaskNumber << endl;

}

// display user''s input
for(int i=0; i<NumberOfTask; i++)
{
cout <<"Number "<< Schedule[i].TaskNumber <<" task takes "
<< Schedule[i].Length <<" minutes."<< endl;
}

// arrange in order of length of task

return 0;
}
//---------------------------------------------------//
How can I solve this?
Please help, thanks :)

推荐答案




Uh ,这是什么问题?


-Kevin

-

我的电子邮件地址有效,但会定期更改。

要联系我,请使用最近发布的地址。



Uh, what''s the question?

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.






松散?何时何地?


-

WW又名阿提拉



Loose? When, where?

--
WW aka Attila


这篇关于为什么我不能在这种情况下通过值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 16:34