Sei sulla pagina 1di 4

package Camino;

import javax.swing.JOptionPane;

/**

* @author lafa_

*/

public class Corto extends javax.swing.JFrame {

int co[];

int p[];

int vuelta[];

int q;

int procesos_originales[];

int tamar;

int c = 0;

int temp = 0;

int total = 0;
float tiempo_espera, tiempo_ida;

/**

* Creates new form UNO

*/

public Corto() {

initComponents();

public void sjf(){

tamar=Integer.parseInt(nprocesos.getText());

int p[] = new int[tamar];

int co[] = new int[tamar];

int es[] = new int[tamar];

int vuelta[] = new int[tamar];

int procesos_originales[] = new int[tamar];

for (int i = 0; i < tamar; i++) {

procesos_originales[i] = co[i] = p[i] =


Integer.parseInt(JOptionPane.showInputDialog("introduza el tamanio "

+ "del proceso [" + (i + 1) + "]"));

for (int i = 0; i < tamar - 1; i++) {

for (int j = i + 1; j < tamar; j++) {

if (p[i] > p[j]) {

temp = p[i];

p[i] = p[j];

p[j] = temp;

}
for (int i = 0; i < p.length; i++) {

txtoriginales.append("\nP[" + (i + 1) + "] : " + p[i] + "\t");

for (int i = 0; i < tamar - 1; i++) {

for (int j = i + 1; j < tamar; j++) {

if (co[i] > co[j]) {

temp = co[i];

co[i] = co[j];

co[j] = temp;

vuelta[0] = 0;

for (int i = 1; i < tamar; i++) {

vuelta[i] = vuelta[i - 1] + co[i - 1];

total = total + vuelta[i];

for (int i = 0; i < p.length; i++) {

es[i] = vuelta[i] + co[i];

tiempo_espera += vuelta[i];

tiempo_ida += es[i];

txtordenados.append("\nP[" + (i + 1) + "] : " + procesos_originales[i] + "\t");

txtesta.append("\nProceso\ttamaño\tespera\tida");

for (int i = 0; i < p.length; i++) {

txtesta.append("\np[" + (i + 1) + "] \t " + co[i] + "\t " + vuelta[i] + "\t" + es[i]);


}

promedioespera.setText(""+(tiempo_espera / tamar));

promedioida.setText("" + (tiempo_ida / tamar));

Potrebbero piacerti anche