-
-
Save MahmoudMabrok/77c53b3066efd7c96b28f3350482098c to your computer and use it in GitHub Desktop.
aa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
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
4
100 42
42 100
5 42
100 5