Exemple #1
0
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    String line = System.getProperty("line.separator");
    scan.useDelimiter(line);

    int cases = scan.nextInt();

    for (int x = 0; x < cases; x++) {

      String[] get = scan.next().split(" ");

      System.out.println(Integer.parseInt(get[0]) % Integer.parseInt(get[1]));
    }
  }
Exemple #2
0
  public static LinkedList<profile> importer() throws IOException {

    LinkedList<profile> people = new LinkedList<profile>();
    Scanner sFile;
    profile entry;

    try {
      sFile =
          new Scanner(new File("/Users/richarddavies/NetBeansProjects/typ_MatlabGraph/users.dat"));
      sFile.nextLine();
      while (sFile.hasNext()) {

        String profile = sFile.nextLine();
        // System.out.println(profile);

        Scanner profScan = new Scanner(profile);
        profScan.useDelimiter(",");

        while (profScan.hasNext()) {

          Long id = profScan.nextLong();
          String ident = String.valueOf(id);
          String rot_Id = rot13.encrypt(ident);
          Long rot_IntId = Long.parseLong(rot_Id);

          String fname = profScan.next();
          String rot_Name = rot13.encrypt(fname);
          // String sname = profScan.next();
          // int age = profScan.nextInt();
          String gender = profScan.next();
          String nat = profScan.next();

          entry = new profile(id, fname, gender, nat);
          // System.out.println("id: "+id+" name: "+fname+" gender: "+gender+" nationality: "+nat);
          // System.out.println("id: "+rot_IntId+" name: "+rot_Name+" gender: "+gender+"
          // nationality: "+nat);
          people.add(entry);
        }
      }

    } catch (IOException ex) {
      // return people;

      System.out.println("(No System File profile.txt)" + ex);
    }
    return people;
  }
Exemple #3
0
  public static LinkedList<edge> importer(MatlabProxy proxy)
      throws IOException, MatlabConnectionException, MatlabInvocationException {

    Scanner sFile;
    edge entry;
    LinkedList<edge> tie = new LinkedList<edge>();
    Long k, p;

    try {
      sFile =
          new Scanner(new File("/Users/richarddavies/NetBeansProjects/typ_MatlabGraph/edges.dat"));

      System.out.println(sFile.nextLine());

      while (sFile.hasNext()) {

        String edge = sFile.nextLine();
        // System.out.println(edge);

        Scanner edgeScan = new Scanner(edge);
        edgeScan.useDelimiter(",");

        while (edgeScan.hasNext()) {

          k = edgeScan.nextLong();
          System.out.print(k + " ");

          String ident_k = String.valueOf(k);
          String rot_Id_k = rot13.encrypt(ident_k);
          Long rot_k = Long.parseLong(rot_Id_k);

          p = edgeScan.nextLong();
          System.out.print(p);

          String ident_p = String.valueOf(p);
          String rot_Id_p = rot13.encrypt(ident_p);
          Long rot_p = Long.parseLong(rot_Id_p);

          // System.out.println(rot_k+" : "+rot_p);
          entry = new edge(k, p);

          int n = search.search(k);
          int m = search.search(p);
          System.out.print(
              " : "
                  + Typ_MatlabGraph.people.get(n).idProf
                  + " "
                  + Typ_MatlabGraph.people.get(m).idProf);
          System.out.println("");
          n++;
          m++;

          proxy.eval("adjMatrix(" + n + "," + m + ") = 1");

          tie.add(entry);
        }
      }

    } catch (IOException ex) {

      System.out.println("(No System File profile.txt)" + ex);
    }

    return tie;
  }