PTA 操作系统 作业调度算法--先来先服务
#include <iostream>#include <iomanip>
using namespace std;
void Scheduling(char name[], int table[], int col);
int main(){
int thread;
cin >> thread;
char *name = new char;
int (*table) = new int;
for(int i = 0; i < thread; i++)
cin >> name;
for(int i = 0; i < 2; i++){
for(int j = 0; j < thread; j++)
cin >> table;
}
Scheduling(name, table, thread);
return 0;
}
void Scheduling(char name[], int table[], int col){
cout << "作 业 名:";
for(int i = 0; i < col; i++){
if(i != 0) cout << " ";
cout << name;
}
cout << endl;
cout << "到达时间:";
for(int i = 0; i < col; i++){
if(i != 0) cout << " ";
cout << table;
}
cout << endl;
cout << "服务时间:";
for(int i = 0; i < col; i++){
if(i != 0) cout << " ";
cout << table;
}
cout << endl;
int *finish = new int;
finish = table + table;
for(int i = 1; i < col; i++)
finish = finish + table;
int *turnover = new int;
for(int i = 0; i < col; i++)
turnover = finish - table;
double *power = new double;
for(int i = 0; i < col; i++)
power = (double)turnover/table;
cout << "完成时间:";
for(int i = 0; i < col; i++){
if(i != 0) cout << " ";
cout << finish;
}
cout << endl;
cout << "周转时间:";
for(int i = 0; i < col; i++){
if(i != 0) cout << " ";
cout << turnover;
}
cout << endl;
cout << "带权周转时间:";
for(int i = 0; i < col; i++){
if(i != 0) cout << " ";
cout.setf(ios::fixed);
cout << setprecision(2) << power;
}
cout << endl;
}
在PTA提交的时候,出现4种情况
只得了case0的分,请大佬们说明其他3种情况是什么,并提出改正。
谢谢
题目是啥 永恒的蓝色梦想 发表于 2020-11-21 22:29
题目是啥
你有对作业按照到达时间排序吗? 赚小钱 发表于 2020-11-22 21:52
你有对作业按照到达时间排序吗?
已排好序
将代码做个备份。
恕我眼拙,能否告知从第几行到第几行是排序的逻辑。
页:
[1]