Skip to content

Instantly share code, notes, and snippets.

@MahmoudMabrok
Created July 1, 2019 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MahmoudMabrok/77c53b3066efd7c96b28f3350482098c to your computer and use it in GitHub Desktop.
Save MahmoudMabrok/77c53b3066efd7c96b28f3350482098c to your computer and use it in GitHub Desktop.
aa
import java.util.Scanner;
public class Try {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
Scanner S=new Scanner(System.in);
String []s=new String[30];
for (int i = 0; i < n; i++) {
s[i]=S.nextLine();
}
String []tm=new String [2];
String []tm2=new String [2];
int c=0;
for(int i=0;i<n;i++)
{
tm=s[i].split(" ");
for(int j=0;j<i;j++)
{
tm2=s[j].split(" ");
if( tm[0].matches(tm2[1]))
c++;
if(tm[1].matches(tm2[0]))
c++;
}
}
System.out.print(c);
}
}
@MahmoudMabrok
Copy link
Author

4
100 42
42 100
5 42
100 5

@MahmoudMabrok
Copy link
Author

MahmoudMabrok commented Jul 1, 2019

package utitity.mahmoud.junittutorial;

import java.util.Scanner;

public class Test {

    public static void main(String[] args) {
        Scanner S = new Scanner(System.in);
        int n=Integer.parseInt(S.nextLine());
        String []s=new String[30];
        for (int i = 0; i < n; i++) {
            s[i]=S.nextLine();
        }
        String []tm=new String [2];
        String []tm2=new String [2];
        int c=0;
        for(int i=0;i<n;i++)
        {
            tm=s[i].split(" ");
            for(int j=0;j<i;j++)
            {
                tm2=s[j].split(" ");
                if( tm[0].matches(tm2[1]))
                    c++;
                if(tm[1].matches(tm2[0]))
                    c++;

            }
        }
        System.out.print(c);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment