Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 21st, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class Funcionario{
  2.         int num,horai,horaf;
  3.         Funcionario(int n, int i, int f){
  4.                 num=n;
  5.                 horai=i;
  6.                 horaf=f;
  7.         }
  8.         public void checkTime(int newI, int newF){
  9.                 if(horai>newI){
  10.                         horai=newI;
  11.                 }
  12.                 if(horaf<newF){
  13.                         horaf= newF;
  14.                 }
  15.         }
  16. }
  17. public class Topas_A {
  18.         public static void main (String arg[]){
  19.                 Scanner in = new Scanner(System.in);
  20.                 int k=0;
  21.                 int virusI, virusF;
  22.                 int nFuncionarios;
  23.                 int n,newI, newF;
  24.                 virusI = in.nextInt();
  25.                 virusF = in.nextInt();
  26.                 nFuncionarios = in.nextInt();
  27.                 Funcionario funcionarios[] = new Funcionario[100];
  28.                 for(int i = 0; i<nFuncionarios; i++){
  29.                         n = in.nextInt();
  30.                         newI=in.nextInt();
  31.                         newF= in.nextInt();
  32.                         if(funcionarios[n-1]!= null){
  33.                                 funcionarios[n-1].checkTime(newI, newF);
  34.                         }else{
  35.                                 funcionarios[n-1]= new Funcionario(n,newI,newF);
  36.                         }
  37.                 }
  38.                 for(int i = 0; i<100;i++){
  39.                         if(funcionarios[i]!=null){
  40.                                 if((funcionarios[i].horai<virusI) && (funcionarios[i].horaf > virusF)){
  41.                                         k++;
  42.                                 }
  43.                         }
  44.                 }
  45.                 System.out.print(k);
  46.         }
  47.        
  48. }