n; 对于(i=1;i,c++,c,algorithm,C++,C,Algorithm" /> n; 对于(i=1;i,c++,c,algorithm,C++,C,Algorithm" />

为什么我在clrsc()中出错;它说未定义? 我试图清除C++中的屏幕,但是我不能编译这个代码…< /p> #include<iostream> using namespace std; #include<conio.h> #include<stdio.h> class cpuschedule { int n, bu[20]; float twt, awt, wt[20], tat[20]; public: void Getdata(); void fcfs(); void sjf(); void roundrobin(); }; //Getting no of processes and Burst time void cpuschedule::Getdata() { int i; cout << "Enter the no of processes : "; cin >> n; for (i = 1; i <= n; i++) { cout << "\nEnter The BurstTime for Process p"<< i << " = "; cin >> bu[i]; } } //First come First served Algorithm void cpuschedule::fcfs() { int i, b[10]; float sum = 0.0; twt = 0.0; for (i = 1; i <= n; i++) { b[i] = bu[i]; cout << "\nBurst time for process p"<< i << " = "; cout << b[i]; } wt[1] = 0; for (i = 2; i <= n; i++) { wt[i] = b[i - 1] + wt[i - 1]; } for (i = 1; i <= n; i++) { twt = twt + wt[i]; tat[i] = b[i] + wt[i]; sum += tat[i]; } awt = twt / n; sum = sum / n; cout << "\nTotal Waiting Time = " << twt; cout << "\nAverage Waiting Time = " << awt; cout << "\nAverage Turnaround time = " << sum; } //Shortest job First Algorithm void cpuschedule::sjf() { int i, j, temp, b[10]; float sum = 0.0; twt = 0.0; for (i = 1; i <= n; i++) { b[i] = bu[i]; cout << "\nBurst time for process p" << i << " = "; cout << b[i]; } for (i = n; i >= 1; i-) { for (j = 2; j <= n; j++) { if (b[j - 1]>b[j]) { temp = b[j - 1]; b[j - 1] = b[j]; b[j] = temp; } } } wt[1] = 0; for (i = 2; i <= n; i++) { wt[i] = b[i - 1] + wt[i - 1]; } for (i = 1; i <= n; i++) { twt = twt + wt[i]; tat[i] = b[i] + wt[i]; sum += tat[i]; } awt = twt / n; sum = sum / n; cout << "\nTotal Waiting Time = " << twt; cout << "\nAverage Waiting Time = " << awt; cout << "\nAverage turnaround time = " << sum; } //Round Robin Algorithm void cpuschedule::roundrobin() { int i, j, tq, k, b[10], Rrobin[10][10], count[10]; int max = 0; int m; float sum = 0.0; twt = 0.0; for (i = 1; i <= n; i++) { b[i] = bu[i]; cout << "\nBurst time for process p" << i << " = "; cout << b[i]; if (max<b[i]) max = b[i]; wt[i] = 0; } cout << "\nEnter the Time Quantum = "; cin >> tq; //TO find the dimension of the Round robin array m = max / tq + 1; //initializing Round robin array for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { Rrobin[i][j] = 0; } } //placing value in the Rrobin array i = 1; while (i <= n) { j = 1; while (b[i]>0) { if (b[i] >= tq) { b[i] = b[i] - tq; Rrobin[i][j] = tq; j++; } else { Rrobin[i][j] = b[i]; b[i] = 0; j++; } } count[i] = j - 1; i++; } cout <<" Display"; for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { cout << "\nRr[" << i << ", " << j << "] = " << Rrobin[i][j]; cout << " "; } cout << "\ncount = " << count[i]; } for (j = 1; j <= n; j++) { for (i = 1; i <= count[j]; i++) { if (i == count[j]) { for (k = 1; k<j; k++) { if (k != j) wt[j] += Rrobin[k][i]; } } else for (k = 1; k <= n; k++) { if (k != j) wt[j] += Rrobin[k][i]; } } } for (i = 1; i <= n; i++) cout << "\nWaiting Time for process P" << i << " = " << wt[i]; //calculating Average Weighting Time for (i = 1; i <= n; i++) { twt = twt + wt[i]; tat[i] = b[i] + wt[i]; sum += tat[i]; } awt = twt / n; sum = sum / n; cout << "\nTotal Waiting Time = " << twt; cout << "\nAverage Waiting Time = " << awt; cout << "\nAverage turnaround time = " << sum; } void main() { int ch = 0, cho; cpuschedule c; clrscr(); do { switch (ch) { case 0: cout << "\n0.MENU"; cout << "\n1.Getting BurstTime"; cout << "\n2.FirstComeFirstServed"; cout << "\n3.ShortestJobFirst"; cout << "\n4.RoundRobin"; cout << "\n5.EXIT"; break; case 1: c.Getdata(); break; case 2: cout << "FIRST COME FIRST SERVED SCHEDULING"; c.fcfs(); break; case 3: cout << "SHORTEST JOB FIRST SCHEDULING"; c.sjf(); break; case 4: cout << "ROUND ROBIN SCHEDULING"; c.roundrobin(); break; case 5: break; } cout << "\nEnter your choice : "; cin >> ch; getch(); } while (ch<5); } #包括 使用名称空间std; #包括 #包括 类cpuschedule { 国际n,bu[20]; 浮子行波管,awt,wt[20],tat[20]; 公众: void Getdata(); 无效fcfs(); void sjf(); 无效循环(); }; //没有进程和突发时间 void cpuschedule::Getdata() { int i; cout>n; 对于(i=1;i

为什么我在clrsc()中出错;它说未定义? 我试图清除C++中的屏幕,但是我不能编译这个代码…< /p> #include<iostream> using namespace std; #include<conio.h> #include<stdio.h> class cpuschedule { int n, bu[20]; float twt, awt, wt[20], tat[20]; public: void Getdata(); void fcfs(); void sjf(); void roundrobin(); }; //Getting no of processes and Burst time void cpuschedule::Getdata() { int i; cout << "Enter the no of processes : "; cin >> n; for (i = 1; i <= n; i++) { cout << "\nEnter The BurstTime for Process p"<< i << " = "; cin >> bu[i]; } } //First come First served Algorithm void cpuschedule::fcfs() { int i, b[10]; float sum = 0.0; twt = 0.0; for (i = 1; i <= n; i++) { b[i] = bu[i]; cout << "\nBurst time for process p"<< i << " = "; cout << b[i]; } wt[1] = 0; for (i = 2; i <= n; i++) { wt[i] = b[i - 1] + wt[i - 1]; } for (i = 1; i <= n; i++) { twt = twt + wt[i]; tat[i] = b[i] + wt[i]; sum += tat[i]; } awt = twt / n; sum = sum / n; cout << "\nTotal Waiting Time = " << twt; cout << "\nAverage Waiting Time = " << awt; cout << "\nAverage Turnaround time = " << sum; } //Shortest job First Algorithm void cpuschedule::sjf() { int i, j, temp, b[10]; float sum = 0.0; twt = 0.0; for (i = 1; i <= n; i++) { b[i] = bu[i]; cout << "\nBurst time for process p" << i << " = "; cout << b[i]; } for (i = n; i >= 1; i-) { for (j = 2; j <= n; j++) { if (b[j - 1]>b[j]) { temp = b[j - 1]; b[j - 1] = b[j]; b[j] = temp; } } } wt[1] = 0; for (i = 2; i <= n; i++) { wt[i] = b[i - 1] + wt[i - 1]; } for (i = 1; i <= n; i++) { twt = twt + wt[i]; tat[i] = b[i] + wt[i]; sum += tat[i]; } awt = twt / n; sum = sum / n; cout << "\nTotal Waiting Time = " << twt; cout << "\nAverage Waiting Time = " << awt; cout << "\nAverage turnaround time = " << sum; } //Round Robin Algorithm void cpuschedule::roundrobin() { int i, j, tq, k, b[10], Rrobin[10][10], count[10]; int max = 0; int m; float sum = 0.0; twt = 0.0; for (i = 1; i <= n; i++) { b[i] = bu[i]; cout << "\nBurst time for process p" << i << " = "; cout << b[i]; if (max<b[i]) max = b[i]; wt[i] = 0; } cout << "\nEnter the Time Quantum = "; cin >> tq; //TO find the dimension of the Round robin array m = max / tq + 1; //initializing Round robin array for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { Rrobin[i][j] = 0; } } //placing value in the Rrobin array i = 1; while (i <= n) { j = 1; while (b[i]>0) { if (b[i] >= tq) { b[i] = b[i] - tq; Rrobin[i][j] = tq; j++; } else { Rrobin[i][j] = b[i]; b[i] = 0; j++; } } count[i] = j - 1; i++; } cout <<" Display"; for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { cout << "\nRr[" << i << ", " << j << "] = " << Rrobin[i][j]; cout << " "; } cout << "\ncount = " << count[i]; } for (j = 1; j <= n; j++) { for (i = 1; i <= count[j]; i++) { if (i == count[j]) { for (k = 1; k<j; k++) { if (k != j) wt[j] += Rrobin[k][i]; } } else for (k = 1; k <= n; k++) { if (k != j) wt[j] += Rrobin[k][i]; } } } for (i = 1; i <= n; i++) cout << "\nWaiting Time for process P" << i << " = " << wt[i]; //calculating Average Weighting Time for (i = 1; i <= n; i++) { twt = twt + wt[i]; tat[i] = b[i] + wt[i]; sum += tat[i]; } awt = twt / n; sum = sum / n; cout << "\nTotal Waiting Time = " << twt; cout << "\nAverage Waiting Time = " << awt; cout << "\nAverage turnaround time = " << sum; } void main() { int ch = 0, cho; cpuschedule c; clrscr(); do { switch (ch) { case 0: cout << "\n0.MENU"; cout << "\n1.Getting BurstTime"; cout << "\n2.FirstComeFirstServed"; cout << "\n3.ShortestJobFirst"; cout << "\n4.RoundRobin"; cout << "\n5.EXIT"; break; case 1: c.Getdata(); break; case 2: cout << "FIRST COME FIRST SERVED SCHEDULING"; c.fcfs(); break; case 3: cout << "SHORTEST JOB FIRST SCHEDULING"; c.sjf(); break; case 4: cout << "ROUND ROBIN SCHEDULING"; c.roundrobin(); break; case 5: break; } cout << "\nEnter your choice : "; cin >> ch; getch(); } while (ch<5); } #包括 使用名称空间std; #包括 #包括 类cpuschedule { 国际n,bu[20]; 浮子行波管,awt,wt[20],tat[20]; 公众: void Getdata(); 无效fcfs(); void sjf(); 无效循环(); }; //没有进程和突发时间 void cpuschedule::Getdata() { int i; cout>n; 对于(i=1;i,c++,c,algorithm,C++,C,Algorithm,我为您编写了一个小示例。我假设您正在windows上运行 #include <iostream> #include <string> using namespace std; #include <stdio.h> // include this for the clear int main() { string usersInput; cout <<"Enter string: "; getline(cin,usersInput);

我为您编写了一个小示例。我假设您正在windows上运行

#include <iostream>
#include <string>
using namespace std;

#include <stdio.h> // include this for the clear

int main()
{
  string usersInput;
  cout <<"Enter string: ";
  getline(cin,usersInput);

  cout << "The string is: " << usersInput << endl;

  cout << "Press Enter to clear screen.";

  cin.ignore();
  system("CLS"); // this clears the screen

  cin.ignore();
  return 0;
}
#包括
#包括
使用名称空间std;
#include//include此项用于清除
int main()
{
字符串用户输入;

CUT<代码> CrrScript()/Cuth>不是标准C++函数。我还能使用其他函数吗?没有标准的清除屏幕的方法。它取决于开发环境、库等。你需要找出一些东西。如果所有其他的都失败了,你可以做很多<代码> Prtuf(“\n \n \n \n \n \n \n \n));< /C> >排序“清除”。屏幕。请阅读如何创建一个-您发布的代码远远不是最小的,而且大部分与您描述的问题无关。如果您提供一个有针对性的示例代码,就更容易提供帮助。另外,为什么您认为程序需要清除屏幕?假设您有一个屏幕,这是非常粗鲁的对于单方面覆盖以前命令输出的程序来说,这可能仍然是相关的。而且,根据i/o的连接方式(例如,到管道或到文件),在许多情况下,您没有屏幕。注意:在Ux上,您可以运行而不是运行(有其他方法或命令,但这似乎是最简单的方法)@ CyrPATIATI我从未在UNIX/Linux上编码C++。你需要一个用于ScLear()的明细文件吗?CLAS是:shell命令,所以你也可以用C/C++调用它(就像你对CLS所做的:通过<代码>系统< /C>)。