|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <iostream>
- #include <iomanip>
- using namespace std;
- void Scheduling(char name[], int table[][2], int col);
- int main(){
- int thread;
- cin >> thread;
- char *name = new char[thread];
- int (*table)[2] = new int[thread][2];
- for(int i = 0; i < thread; i++)
- cin >> name[i];
- for(int i = 0; i < 2; i++){
- for(int j = 0; j < thread; j++)
- cin >> table[j][i];
- }
- Scheduling(name, table, thread);
- return 0;
- }
- void Scheduling(char name[], int table[][2], int col){
- cout << "作 业 名:";
- for(int i = 0; i < col; i++){
- if(i != 0) cout << " ";
- cout << name[i];
- }
- cout << endl;
- cout << "到达时间:";
- for(int i = 0; i < col; i++){
- if(i != 0) cout << " ";
- cout << table[i][0];
- }
- cout << endl;
- cout << "服务时间:";
- for(int i = 0; i < col; i++){
- if(i != 0) cout << " ";
- cout << table[i][1];
- }
- cout << endl;
- int *finish = new int[col];
- finish[0] = table[0][0] + table[0][1];
- for(int i = 1; i < col; i++)
- finish[i] = finish[i-1] + table[i][1];
- int *turnover = new int[col];
- for(int i = 0; i < col; i++)
- turnover[i] = finish[i] - table[i][0];
- double *power = new double[col];
- for(int i = 0; i < col; i++)
- power[i] = (double)turnover[i]/table[i][1];
- cout << "完成时间:";
- for(int i = 0; i < col; i++){
- if(i != 0) cout << " ";
- cout << finish[i];
- }
- cout << endl;
- cout << "周转时间:";
- for(int i = 0; i < col; i++){
- if(i != 0) cout << " ";
- cout << turnover[i];
- }
- cout << endl;
- cout << "带权周转时间:";
- for(int i = 0; i < col; i++){
- if(i != 0) cout << " ";
- cout.setf(ios::fixed);
- cout << setprecision(2) << power[i];
- }
- cout << endl;
- }
复制代码
在PTA提交的时候,出现4种情况
只得了case0的分,请大佬们说明其他3种情况是什么,并提出改正。
谢谢
|
|