示例#1
0
 @Override
 public int Add() { // 增加资产
   Class_ManageDao cm = new Class_ManageDaoImpl();
   Scanner input = new Scanner(System.in);
   // 向资产表中添加数据
   System.out.println("请输入要增加的资产name");
   String name = input.next();
   System.out.println("请输入要增加的资产mainclass");
   String mainclass = input.next();
   System.out.println("请输入要增加的资产model");
   String model = input.next();
   System.out.println("请输入要增加的资产value");
   int value = input.nextInt();
   System.out.println("请输入要增加的资产date");
   String date = input.next();
   System.out.println("请输入要增加的资产status");
   int status = input.nextInt();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   try {
     Date Occ_Date = sdf.parse(date);
   } catch (ParseException e) {
     e.printStackTrace();
   }
   String sql =
       "insert into Fixed_Assets (Assets_name,MainClass,Model,Value,Buy_date,Status) values (?,?,?,?,?,?)";
   Object[] param = {name, mainclass, model, value, date, status};
   int result = this.exceuteUpdate(sql, param);
   // 检查类表中是否有该大类,没有则添加
   // 有该大类时,函数返回true,否则返回false
   if (!cm.getByClassName(mainclass)) {
     cm.Add(mainclass);
   }
   return result;
 }
示例#2
0
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int T = sc.nextInt();

    long d3 = 3, d5 = 5, d15 = 15;
    long n3 = 0, n5 = 0, n15 = 0;
    if ((1 <= T) && (T <= 100000)) {
      for (int j = 0; j < T; j++) {
        long sum3 = 0, sum5 = 0, sum15 = 0, sum = 0;
        long l3, l5, l15 = 0;

        int N = sc.nextInt();
        if ((1 <= N) && (N <= 1000000000)) {
          N = N - 1;
          l3 = N % 3;
          l3 = N - l3;
          n3 = (l3 - 3) / 3 + 1;
          sum3 = (3 * ((n3) + 1) * (n3)) / 2;

          l5 = N % 5;
          l5 = N - l5;
          n5 = (l5 - 5) / 5 + 1;
          sum5 = (5 * ((n5) + 1) * (n5)) / 2;

          l15 = N % 15;
          l15 = N - l15;
          n15 = (l15 - 15) / 15 + 1;
          sum15 = (15 * ((n15) + 1) * (n15)) / 2;

          sum = sum3 + sum5 - sum15;
          System.out.println(sum);
        }
      }
    }
  }
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int v = input.nextInt();
    boolean[] canBuy = new boolean[n];
    int canBuyCounter = 0;
    for (int i = 0; i < n; i++) {
      int n1 = input.nextInt();
      int[] prices = new int[n1];
      for (int j = 0; j < n1; j++) {
        prices[j] = input.nextInt();
      }
      for (int j : prices) {
        if (v > j) {
          canBuyCounter++;
          canBuy[i] = true;
          break;
        }
      }
    }

    System.out.println(canBuyCounter);
    boolean firstPrint = true;
    for (int i = 0; i < n; i++) {
      if (canBuy[i]) {
        if (firstPrint) {
          firstPrint = false;
        } else {
          System.out.print(" ");
        }
        System.out.print((i + 1));
      }
    }
    System.out.println();
  }
示例#4
0
文件: Main.java 项目: rleong/Lab1
  public static void askInput() { // Ask for inputs into variables

    System.out.println("How many years are you planning on working?");
    yearsToWork = reader.nextInt();

    System.out.println("Please enter a number from 0 to 20:");
    System.out.println("What is your expected average return in investment?");
    annualReturn = reader.nextDouble();
    // Must be in range of 0-20, if not, prompts the user again for the correct input
    while (annualReturn < 0 || annualReturn > 20) {
      System.out.println("Please enter a number from 0 to 20!");
      System.out.println("What is your expected average return in investment?");
      annualReturn = reader.nextDouble();
    }

    System.out.println("How many years are you expecting to retire for?");
    yearsRetired = reader.nextInt();

    System.out.println("Please enter a number from 0 to 3!");
    System.out.println("What is your expected annual return from retirement?");
    annualRetirement = reader.nextDouble();
    // Must be in the range of 0-3, if not, prompts the user again for the correct input
    while (annualRetirement < 0 || annualRetirement > 3) {
      System.out.println("Please enter a number from 0 to 3!");
      System.out.println("What is your expected annual return from retirement?");
      annualRetirement = reader.nextDouble();
    }

    System.out.println("What is your required income?");
    requiredIncome = reader.nextDouble();

    System.out.println("What is your expected Social Security Income?");
    monthlySSI = reader.nextDouble();
  }
  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    int nodeCount = scanner.nextInt();
    int[] weightArr = new int[nodeCount + 1];
    GraphNode[] nodeArr = new GraphNode[nodeCount + 1];
    scanner.nextLine();
    for (int j = 1; j <= nodeCount; j++) {
      weightArr[j] = scanner.nextInt();
      sumOfAll += weightArr[j];
    }
    for (int j = 1; j <= nodeCount; j++) {
      nodeArr[j] = new GraphNode(j, weightArr[j]);
    }

    scanner.nextLine();

    for (int i = 1; i < nodeCount; i++) {
      int k = scanner.nextInt();
      int v = scanner.nextInt();
      nodeArr[k].list.add(nodeArr[v]);
      nodeArr[v].list.add(nodeArr[k]);
      scanner.nextLine();
    }

    minDifference(nodeArr[1], nodeArr[1], weightArr);
    System.out.println(ans);
  }
  public static void main(String[] args) {

    Random r = new Random();
    int n = r.nextInt(101);
    System.out.println(n);
    Scanner s = new Scanner(System.in);
    System.out.println("Estoy pensando un numero entre el 1 y el 100, cual crees que es?");
    int num = s.nextInt();

    int i = 1;
    while (num != n) {

      if (num > n) {
        System.out.println("menos: ");
        num = s.nextInt();
      } else if (num < n) {
        System.out.println("mas: ");
        num = s.nextInt();
      }

      i++;
    }

    System.out.println("ese es el numero! y lo atinaste en el intento: " + i);
  }
示例#7
0
  /** Reads in the letter location data for the word hunt puzzle */
  public static void readPuzzle() {
    letters = new String[3][3][2];

    try {
      Scanner reader = new Scanner(new File("graph.txt"));

      while (reader.hasNext()) {
        String temp = reader.next();
        // if the String is not a number it is a character
        if (!NUMBERS.contains(temp)) {
          // find the coordinates of the letter/String
          int x = reader.nextInt();
          int y = reader.nextInt();
          int z = reader.nextInt();
          letters[x][y][z] = temp;
        }
      }

      // prints out the word hunt set up, in separate squares that represent the 2D arrays at each
      // depth
      for (int k = 0; k < 2; k++) {
        for (int i = 0; i < 3; i++) {
          for (int j = 0; j < 3; j++) {
            System.out.print(letters[i][j][k] + " ");
          }
          System.out.print("\n");
        }
        System.out.print("\n");
      }
    } catch (FileNotFoundException e) {
      System.out.println("No such file.");
    }
  }
示例#8
0
文件: P1049.java 项目: ifayne/akoj
 public static void main(String[] args) {
   int n = cin.nextInt();
   int p = cin.nextInt();
   int a[][] = new int[n][n];
   if (p == 1)
     for (int j = 0; j < n; j++) {
       for (int i = n - 1; i >= 0; i--) {
         a[i][j] = cin.nextInt();
       }
     }
   else if (p == 2)
     for (int i = n - 1; i >= 0; i--) {
       for (int j = n - 1; j >= 0; j--) {
         a[i][j] = cin.nextInt();
       }
     }
   else if (p == 3)
     for (int j = n - 1; j >= 0; j--) {
       for (int i = 0; i < n; i++) {
         a[i][j] = cin.nextInt();
       }
     }
   for (int i = 0; i < n; i++) {
     for (int j = 0; j < n; j++) {
       System.out.print(a[i][j] + " ");
     }
     System.out.println();
   }
   cin.close();
 }
示例#9
0
  public static void main(String args[]) {

    Scanner in = new Scanner(System.in);

    int n = in.nextInt();
    int[] arr = new int[n];

    for (int i = 0; i < n; ++i) arr[i] = in.nextInt();

    int count = 0;
    for (int j = 1; j < n; ++j) {

      int key = arr[j];
      int i = j - 1;

      while (i >= 0 && arr[i] > key) {
        arr[i + 1] = arr[i];
        --i;
        ++count;
      }
      arr[i + 1] = key;
    }

    System.out.println(count);
  }
示例#10
0
  public static void main(String args[]) {
    Scanner cin = new Scanner(System.in);

    int num = cin.nextInt();
    for (int i = 0; i < num; i++) {
      int policy = cin.nextInt();
      int english = cin.nextInt();
      int math = cin.nextInt();
      int major = cin.nextInt();

      int total = policy + english + math + major;
      // 如果是Fail
      if (policy < 60 || english < 60 || math < 90 || major < 90 || total < 310) {
        System.out.println("Fail");
      }
      // 如果是Zifei
      else if (total < 350) {
        System.out.println("Zifei");
      }
      // 如果是Gongfei
      else {
        System.out.println("Gongfei");
      }
    }
  }
示例#11
0
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = Integer.parseInt(scanner.nextLine());

    // Create all the vertices first.
    Vertex[] vertices = new Vertex[n];
    for (int i = 0; i < n; ++i) {
      vertices[i] = new Vertex(scanner.nextInt());
    }
    scanner.nextLine();

    // Connect the vertices.
    int parent, child;
    while (n > 1) {
      parent = scanner.nextInt() - 1;
      child = scanner.nextInt() - 1;
      vertices[parent].connectWith(vertices[child]);
      n--;
    }

    // Calculate the weights of all the vertices.
    Vertex root = vertices[0];
    root.calculateWeight();

    // Calculate the smallest possible difference when removing an edge.
    System.out.println(root.calculateSmallestDiff());
  }
示例#12
0
 public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   while (true) {
     int n = sc.nextInt();
     if (n < 0) return;
     double pago = sc.nextDouble();
     double inicial = sc.nextDouble();
     int nval = sc.nextInt();
     for (int i = 0; i <= n; i++) {
       prc[i] = Double.POSITIVE_INFINITY;
     }
     for (int i = 0; i < nval; i++) {
       int pos = sc.nextInt();
       prc[pos] = sc.nextDouble();
     }
     double prcAnt = prc[0];
     double deuda = inicial;
     inicial += pago;
     pago = deuda / n;
     inicial = inicial - inicial * prcAnt;
     int i;
     for (i = 1; i <= n; i++) {
       if (deuda < inicial) {
         i = 0;
         break;
       }
       deuda -= pago;
       if (prc[i] != Double.POSITIVE_INFINITY) prcAnt = prc[i];
       inicial = inicial - inicial * prcAnt;
       if (deuda < inicial) break;
     }
     if (i == 1) System.out.println("1 month");
     else System.out.println(i + " months");
   }
 }
示例#13
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub

    @SuppressWarnings("resource")
    Scanner s = new Scanner(System.in);
    int n1;
    int n2;
    int r1;
    int r2;
    int r;

    System.out.print("Digite uma nota:");
    n1 = s.nextInt();

    System.out.print("Digite uma outra nota:");
    n2 = s.nextInt();

    r1 = n1 * n2;

    System.out.print("O primeiro resultado é:\n" + r1);

    System.out.print("Digite um divisor:");
    r2 = s.nextInt();

    r = r1 / r2;

    System.out.print("O resultado final é:" + r);
  }
  /** @param args */
  public static void main(String[] args) {
    int number1 = (int) (System.currentTimeMillis() % 10);
    int number2 = (int) (System.currentTimeMillis() / 7 % 10);
    HashSet<Integer> enteredNumbers = new HashSet<Integer>();
    Scanner input = new Scanner(System.in);

    System.out.print("What is " + number1 + " + " + number2 + " ? ");
    int enteredNumber = input.nextInt();

    int calculation = number1 + number2;

    while (enteredNumber != calculation) {
      if (enteredNumbers.contains(enteredNumber)) {
        System.out.println("You already entered 12");
        System.out.print("Wrong answer. Try again ! What is " + number1 + " + " + number2 + " ? ");
        enteredNumber = input.nextInt();
      } else {
        System.out.print("Wrong answer. Try again ! What is " + number1 + " + " + number2 + " ? ");
        enteredNumbers.add(enteredNumber);
        enteredNumber = input.nextInt();
      }
    }

    System.out.println("You got it ! Congratz !");
    enteredNumbers.clear();
    input.close();
  }
示例#15
0
  private static UnivariatePalette readPalette(Scanner scan) {
    String line = scan.nextLine();
    Scanner lineScan = new Scanner(line);
    lineScan.useDelimiter(",");

    String name = lineScan.next();
    int maxLength = lineScan.nextInt();
    SequenceType type = findSequenceType(lineScan.next());
    HashMap<Integer, Color[]> colorMap = new HashMap<Integer, Color[]>();
    Color[] colors = new Color[maxLength];
    for (int i = 0; i < maxLength; i++) {
      if (i > 0) {
        line = scan.nextLine();
        lineScan = new Scanner(line);
        lineScan.useDelimiter(",");
        lineScan.next();
        lineScan.next();
      }
      String indexString = lineScan.next();
      int index = Integer.valueOf(indexString);
      assert (i == index - 1);
      lineScan.next(); // skip letter
      int r = lineScan.nextInt();
      int g = lineScan.nextInt();
      String bString = lineScan.next();
      // logger.info("bString = " + bString);
      int b = Integer.valueOf(bString.trim());
      Color col = new Color(r, g, b);
      colors[i] = col;
    }
    colorMap.put(maxLength, colors);

    UnivariatePalette pal = new UnivariatePalette(name, type, colorMap, maxLength);
    return pal;
  }
 public static void main(String args[]) {
   Scanner s1 = new Scanner(System.in);
   int len = s1.nextInt();
   int freq[] = new int[100001];
   int starts[] = new int[100001];
   int big = 0;
   int small = len + 1;
   int end = 0, size = 0, l = 0, r = 0;
   int curr;
   for (int i = 0; i < len; i++) {
     curr = s1.nextInt();
     if (freq[curr] == 0) {
       starts[curr] = i;
       freq[curr] = 1;
     } else {
       (freq[curr])++;
       end = i;
     }
     if (freq[curr] >= big) {
       big = freq[curr];
       size = (end) - starts[curr] + 1;
       if (size < small) {
         small = size;
         l = starts[curr] + 1;
         r = end + 1;
       }
     }
   }
   s1.close();
   System.out.print(l + " " + r);
 }
示例#17
0
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int T = sc.nextInt();
    while (T-- > 0) {
      int R = sc.nextInt();
      int C = sc.nextInt();
      int[] hp = new int[2];
      int[] exit = new int[2];
      char[][] forest = new char[R][C];

      for (int i = 0; i < R; ++i) {
        String str = sc.next();
        for (int j = 0; j < C; ++j) {
          if (str.charAt(j) == 'M') {
            forest[i][j] = '.';
            hp[0] = i;
            hp[1] = j;
          } else if (str.charAt(j) == '*') {
            forest[i][j] = '.';
            exit[0] = i;
            exit[1] = j;
          } else {
            forest[i][j] = str.charAt(j);
          }
        }
      }

      int result = Solution.countWandWaving(forest, hp, exit);
      // System.out.println(result);
      if (result == sc.nextInt()) {
        System.out.println("Impressed");
      } else System.out.println("Oops!");
    }
  }
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    // Read in the number of elements
    int n = in.nextInt();

    // Store the list of cities in an array
    int[] cities = new int[n];
    for (int i = 0; i < n; i++) {
      cities[i] = in.nextInt();
    }

    // Since the list is in ascending order (as specified in the problem
    // statement), the minimum difference will be to either the left or right
    // of the element, and the maximum will either be to the first or last
    // element
    for (int i = 0; i < n; i++) {
      int left = Integer.MAX_VALUE;
      int right = Integer.MAX_VALUE;
      if (i > 0) {
        left = Math.abs(cities[i] - cities[i - 1]);
      }
      if (i < n - 1) {
        right = Math.abs(cities[i] - cities[i + 1]);
      }
      int min = Math.min(left, right);

      left = Math.abs(cities[i] - cities[0]);
      right = Math.abs(cities[i] - cities[n - 1]);
      int max = Math.max(left, right);

      System.out.println(min + " " + max);
    }
  }
示例#19
0
  public static void main(String[] args) {
    /** 6 9 1 2 2 1 4 5 1 3 1 2 6 1 2 4 2 3 4 1 4 6 3 4 5 2 5 3 4 */
    int vertices, edges, i, v, v1, v2;
    Scanner s = new Scanner(System.in);

    vertices = s.nextInt();
    edges = s.nextInt();
    /* This is the table of our Adjacency List
     * Each element holds a Linked List
     */
    Node[] adjanceyList = new Node[vertices + 1];

    for (i = 0; i <= vertices; ++i) {
      // Initialising our arrays
      adjanceyList[i] = null;
    }

    for (i = 1; i <= edges; ++i) {
      v1 = s.nextInt();
      v2 = s.nextInt();
      int weight = s.nextInt();
      adjanceyList[v1] = insert(adjanceyList[v1], v2, weight);
    }

    shortestArray = new int[adjanceyList.length];
    dijsktra(adjanceyList);
    for (i = 1; i < shortestArray.length; i++) {
      System.out.println(i + "-> " + shortestArray[i]);
    }
  }
示例#20
0
  public static void main(String[] args) {
    int km, litros, kmTotal, litrosTotal;
    Scanner input = new Scanner(System.in);
    Func f = new Func();
    km = 0;
    litros = 0;
    kmTotal = 0;
    litrosTotal = 0;

    do {
      System.out.print("Digite a quilometragem (-1 para sair): ");
      km = input.nextInt();
      if (km >= 0) {
        System.out.print("Digite os litros consumidos: ");
        litros = input.nextInt();
        System.out.println("Consumo: ");
        f.calcula(km, litros);
        kmTotal += km;
        litrosTotal += litros;
      }
    } while (km >= 0);

    System.out.printf("Total de KM: %d\nTotal de Litros: %d\n", kmTotal, litrosTotal);
    System.out.println("FIM!");
  }
示例#21
0
  public static void main(String[] args) {
    //		Cotxe c = new Cotxe();
    //		Scanner entrada = new Scanner(System.in);
    //		System.out.print("Introdueix la marca del cotxe: ");
    //		c.setMarca(entrada.next());
    //		System.out.print("Ara introdueix el model: ");
    //		c.setModel(entrada.next());
    //		System.out.print("Introdueix el nombre de cilindres: ");
    //		c.setCilindrada(Integer.parseInt(entrada.next()));
    //		System.out.print("Introdueix el nombre de cilindrada: ");
    //		c.setCilindres((Integer.parseInt(entrada.next()));
    //		c.calcPotenciaFiscal();
    //		entrada.close();

    CotxeHibrid cH = new CotxeHibrid();
    Scanner entrada = new Scanner(System.in);
    System.out.print("Introdueix la marca del cotxe: ");
    cH.setMarca(entrada.next());
    System.out.print("Ara Introdueix el model: ");
    cH.setModel(entrada.next());
    System.out.print("Introdueix el nombre de cilindres: ");
    cH.setCilindrada(entrada.nextInt());
    System.out.print("Introdueix el nombre de cilindrada: ");
    cH.setCilindres(entrada.nextInt());
    System.out.print("Introdueix els kW del motor: ");
    cH.setkW(Integer.parseInt(entrada.next()));
    System.out.println("");
    System.out.println(
        "El " + cH.marca + " " + cH.model + " té " + cH.calcPotenciaFiscal() + " cavalls fiscals");
    entrada.close();
  }
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int N = in.nextInt();
    int[] arr = new int[N];
    int[] LS = new int[N]; // cache

    for (int i = 0; i < N; i++) {
      arr[i] = in.nextInt();
      LS[i] = 0; // init to zero
    }

    // j<i and a[j] < a[i]
    for (int i = 0; i < N; i++) {
      LS[i] = 1; // trival case, initialises also
      for (int j = 0; j < i; j++) {
        if (arr[j] < arr[i] && LS[j] >= LS[i]) { // second case for
          // undiscovered
          LS[i] = LS[j] + 1;
        }
      }
    }

    int longest = 0;
    for (int i = 0; i < N; i++) {
      if (longest < LS[i]) {
        longest = LS[i];
      }
      System.out.print(LS[i] + " ");
    }

    System.out.println("\n" + longest);

    in.close();
  }
示例#23
0
  public static void main(String args[]) throws Exception {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */

    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    SuperStack stack = new SuperStack();
    PrintWriter out = new PrintWriter(System.out, true);
    for (int i = 0; i < n; i++) {
      String s = in.next();
      if (s.equals("push")) {
        int value = in.nextInt();
        out.println(stack.push(value));
      } else if (s.equals("pop")) {
        int res = stack.pop();
        if (stack.size == 0) {
          out.println("EMPTY");
        } else {
          out.println(res);
        }
      } else if (s.equals("inc")) {
        int x = in.nextInt();
        int d = in.nextInt();
        out.println(stack.inc(x, d));
      }
    }
    out.close();
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int count = sc.nextInt();
    int digitsNum;

    for (int i = 0; i < count; i++) {
      ArrayList<Integer> digits = new ArrayList<>();
      digitsNum = sc.nextInt();
      int result = 0;

      while (digitsNum > 0) {
        digits.add(digitsNum % 10);
        digitsNum = digitsNum / 10;
      }

      Collections.reverse(digits);

      for (int j = 0; j < digits.size(); j++) {
        int digit = digits.get(j);
        result += digit * (j + 1);
      }

      System.out.print(result + " ");
    }

    sc.close();
  }
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    for (; ; ) {
      int seqLen = input.nextInt();
      if (seqLen == 0) break;
      int[] sequence = new int[seqLen];
      for (int i = 0; i < seqLen; i++) {
        sequence[i] = input.nextInt();
      }

      ArrayList<Integer> experiment = new ArrayList<Integer>(seqLen);
      int current = 0;
      for (int i = 1; i <= seqLen; i++) {
        int numAdd = sequence[i - 1] - current;
        for (int j = 0; j < numAdd; j++) {
          experiment.add(i);
          current++;
        }
      }

      for (Integer i : experiment) {
        System.out.print(i + " ");
      }
      System.out.println();
    }
  }
示例#26
0
 public static void main(String[] args) {
   int sum = 0, A, B, tem;
   Scanner sc = new Scanner(System.in);
   System.out.println("Ingresa el valor de A ");
   A = sc.nextInt();
   System.out.println("Ingresa el valor de B ");
   B = sc.nextInt();
   String cad = "";
   for (int i = A; i <= B; i = i + 5) {
     cad = cad + " " + i;
     sum = sum + i;
   }
   System.out.println(cad);
   System.out.println("La suma de los multiplos es:" + sum);
   if (A == 0) {
     System.out.println("El numero " + A + " es nulo");
   }
   if (A > 0) {
     System.out.println("El numero " + A + " es positivo");
   } else {
     System.out.println("El numero " + A + " es negativo");
   }
   if (A < B) {
     tem = A;
     A = B;
     B = tem;
     System.out.println("Ahora el valor de A es: " + A + " y el valor de B es: " + B);
   }
 }
示例#27
0
  public static void main(String[] args) {
    int n;
    Scanner input = new Scanner(System.in);
    // read a number from the console
    do {
      System.out.print("Enter the size of an array: ");
      n = input.nextInt();
    } while (n < 3);

    // declare the array
    int[] array = new int[n];

    // fill the array
    for (int i = 0; i < array.length; i++) {
      System.out.print("Enter a number: ");
      array[i] = input.nextInt();
    }

    input.close();

    // check if the array is zigzag
    boolean isJagged = true;
    for (int i = 1; i < array.length - 1; i += 2) {
      if (!((array[i - 1] < array[i]) && (array[i] > array[i + 1]))) {
        isJagged = false;
        break;
      }
    }
    if (isJagged) {
      System.out.println("изпълнява изискванията за зигзагообразна нагоре редица");
    } else {
      System.out.println("не изпълнява изискванията за зигзагообразна нагоре редица");
    }
  }
示例#28
0
  public static void main(String args[]) {
    Scanner input = new Scanner(System.in);
    int T = input.nextInt();
    CPoint[] array = new CPoint[SIZE];
    for (int t = 0; t < T; t++) {
      int n = input.nextInt();
      for (int i = 0; i < n; i++) {
        int a = input.nextInt();
        int b = input.nextInt();
        array[i] = new CPoint();
        array[i].setPoint(a, b);
      }

      int ans = 0;
      for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < n; j++)
          if (i != j) {
            if (array[j].x > array[i].x && array[j].y > array[i].y) sum++;
            if (array[j].x < array[i].x && array[j].y < array[i].y) sum++;
          }
        if (sum > ans) ans = sum;
      }
      System.out.println(ans);
    }
  }
示例#29
0
  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int start = scan.nextInt();
    int end = scan.nextInt();

    int count = 0;

    for (int i = start; i <= end; i++) {
      String decimalStr = String.valueOf(i);
      for (int j = 0; j < decimalStr.length(); j++) {
        if (decimalStr.charAt(j) == '3'
            || decimalStr.charAt(j) == '6'
            || decimalStr.charAt(j) == '9') {
          count++;
          break;
        } else {
          if ((Integer.parseInt(decimalStr) % 3) == 0) {
            count++;
            break;
          }
        }
      }
    }
    System.out.println(count);
  }
  @Override
  public void startPlayerCardActions() {
    Scanner input = new Scanner(System.in);

    do {
      System.out.println("Want to play 'Scoll' action?\n1-yes\n2-No");
      int value = input.nextInt();

      if (!((value == 1) || (value == 2))) {
        System.out.println("Wrong choice");
        continue;
      }
      // perform scroll
      if (value == 1) {
        scroll();
      }
      break;
    } while (true);

    do {
      System.out.println("Want to play 'Place a Minion' action?\n1-yes\n2-No");
      int value = input.nextInt();

      if (!((value == 1) || (value == 2))) {
        System.out.println("Wrong choice");
        continue;
      }
      // perform take money
      if (value == 1) {
        Helper.placeMinion(board, p);
      }
      break;
    } while (true);
  }