-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6669ac6
commit be14797
Showing
4 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package javaapplication3; | ||
|
||
/** | ||
* @date 03/01/19 | ||
* @author SPREEHA DUTTA | ||
*/ | ||
import java.util.*; | ||
public class circularRotation { | ||
public static boolean circular(List a1,List a2) | ||
{ | ||
int p;int c=0;int i,j=0; | ||
if(a1.size()!=a2.size()) | ||
return false; | ||
else | ||
{ | ||
p=a2.indexOf(a1.get(0)); | ||
if(p!=-1) | ||
{ | ||
for(i=p;i<a2.size();i++) | ||
{ | ||
if(a2.get(i)==a1.get(j)) | ||
{ | ||
c++; | ||
j++; | ||
} | ||
else | ||
break; | ||
} | ||
for(i=0;i<p;i++) | ||
{ | ||
if(a2.get(i)==a1.get(j)) | ||
{ | ||
c++; j++; | ||
} | ||
else | ||
break; | ||
} | ||
} | ||
if(c==a1.size()) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
} | ||
public static void main(String []args) | ||
{ | ||
Scanner sc=new Scanner(System.in); | ||
int m,n,i; | ||
ArrayList<Integer> a = new ArrayList<Integer>(); | ||
ArrayList<Integer> a2 = new ArrayList<Integer>(); | ||
System.out.println("Enter size and insert elements into first array "); | ||
m=sc.nextInt(); | ||
for(i=0;i<m;i++) | ||
a.add(sc.nextInt()); | ||
System.out.println("Enter size and insert elements into second array "); | ||
n=sc.nextInt(); | ||
for(i=0;i<n;i++) | ||
a2.add(sc.nextInt()); | ||
boolean res = circular(a,a2); | ||
System.out.println(res); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package javaapplication3; | ||
|
||
/** | ||
* @date 3/02/19 | ||
* @author SPREEHA DUTTA | ||
*/ | ||
import java.util.*; | ||
public class rotateTile { | ||
public static int[][] rotate(int arr[][]) | ||
{ | ||
int i,j,ri=0; | ||
int rj=arr.length-1; | ||
int rot[][]=new int[arr.length][arr.length]; | ||
for(i=0;i<arr.length;i++) | ||
{ | ||
for(j=0;j<arr.length;j++) | ||
{ | ||
rot[ri][rj]=arr[i][j]; | ||
ri++; | ||
} | ||
rj--; ri=0; | ||
} | ||
return rot; | ||
} | ||
public static void main(String []args) | ||
{ | ||
int n,i,j; | ||
Scanner sc=new Scanner(System.in); | ||
n=sc.nextInt(); | ||
int ri=0,rj=n-1; | ||
int arr[][]=new int[n][n]; | ||
for(i=0;i<n;i++) | ||
for(j=0;j<n;j++) | ||
arr[i][j]=sc.nextInt(); | ||
System.out.println("Original matrix is "); | ||
for(i=0;i<n;i++) | ||
{ | ||
for(j=0;j<n;j++) | ||
{ | ||
System.out.print(arr[i][j]+" "); | ||
} | ||
System.out.println(); | ||
} | ||
int rot[][]=rotate(arr); | ||
System.out.println("Rotated matrix is "); | ||
for(i=0;i<n;i++) | ||
{ | ||
for(j=0;j<n;j++) | ||
{ | ||
System.out.print(rot[i][j]+" "); | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
} |
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