-
Notifications
You must be signed in to change notification settings - Fork 109
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
Showing
50 changed files
with
3,846 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,16 @@ | ||
package Java; | ||
import java.util.*; | ||
public class Ascii { | ||
public static void main(String[] args) { | ||
Scanner sc = new Scanner(System.in); | ||
String s = sc.nextLine(); | ||
char ch = s.charAt(0); | ||
for (int i = 0; i < s.length(); i++) { | ||
if(ch>s.charAt(i)) | ||
{ | ||
ch = s.charAt(i); | ||
} | ||
} | ||
System.out.println(ch); | ||
} | ||
} |
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,38 @@ | ||
// aabbbcc = a2b3c1 | ||
// abbccc = a1b2c3 | ||
import java.util.*; | ||
public class CharRepeat { | ||
public static void main(String[] args) { | ||
Scanner sc = new Scanner(System.in); | ||
String s = sc.nextLine(); | ||
int count=1; | ||
for (int i = 0; i < s.length(); i++) | ||
{ | ||
if(i!=0 && s.charAt(i-1)==s.charAt(i) && i!=(s.length()-1)) | ||
{ | ||
count++; | ||
} | ||
else if(i==(s.length()-1)) | ||
{ | ||
if(s.charAt(i-1)!=(s.charAt(i))) | ||
{ | ||
System.out.print(s.charAt(i-1)+""+count); | ||
count =1; | ||
System.out.print(s.charAt(i)+""+count); | ||
} | ||
else | ||
{ | ||
count++; | ||
System.out.print(s.charAt(i)+""+count); | ||
} | ||
} | ||
else if(i!=0 && s.charAt(i-1)!=(s.charAt(i)) && i!=(s.length()-1)) | ||
{ | ||
System.out.print(s.charAt(i-1)+""+count); | ||
count = 1; | ||
} | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package Java; | ||
import java.util.*; | ||
public class CountRepeatedLetter | ||
{ | ||
public static void main(String[] args) { | ||
Scanner sc = new Scanner(System.in); | ||
String str = sc.nextLine(); | ||
String ch = sc.nextLine(); | ||
String s = str.replace(ch,""); | ||
System.out.println(s); | ||
} | ||
} |
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,34 @@ | ||
package Java; | ||
import java.util.*; | ||
|
||
public class CountVowel { | ||
public static void main(String[] args) { | ||
Scanner sc = new Scanner(System.in); | ||
String s = sc.nextLine(); | ||
int v =0; | ||
int c=0; | ||
int num=0; | ||
for(int i=0; i<s.length(); i++) | ||
{ | ||
if(Character.isLetter(s.charAt(i))) | ||
{ | ||
if(s.charAt(i)=='A'||s.charAt(i)=='a'||s.charAt(i)=='E'||s.charAt(i)=='e'||s.charAt(i)=='I'||s.charAt(i)=='i'||s.charAt(i)=='O'||s.charAt(i)=='o'||s.charAt(i)=='U'||s.charAt(i)=='u') | ||
{ | ||
v++; | ||
} | ||
else | ||
{ | ||
c++; | ||
} | ||
} | ||
else if(Character.isDigit(s.charAt(i))) | ||
{ | ||
num++; | ||
} | ||
} | ||
System.out.println("Vowel : "+v); | ||
System.out.println("Consonant : "+c); | ||
System.out.println("Number : "+num); | ||
} | ||
|
||
} |
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,116 @@ | ||
package Java; | ||
import java.io.*; | ||
import java.util.*; | ||
import java.text.*; | ||
import java.math.*; | ||
import java.util.regex.*; | ||
|
||
public class DocsWithOddPagesByAssId { | ||
public static void main(String args[] ) throws Exception { | ||
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ | ||
Scanner sc = new Scanner(System.in); | ||
Document[] doc = new Document[4]; | ||
for(int i =0; i<4; i++) | ||
{ | ||
int a = sc.nextInt();sc.nextLine(); | ||
String b = sc.nextLine(); | ||
String c = sc.nextLine(); | ||
int d = sc.nextInt(); | ||
|
||
doc[i] = new Document(a,b,c,d); | ||
} | ||
Document[] d = docWithOddPages(doc); | ||
if(d==null) | ||
{ | ||
System.out.println("All pages are even"); | ||
} | ||
else | ||
{ | ||
for(int i =0; i<d.length; i++) | ||
{ | ||
System.out.println(d[i].getId()+" "+d[i].getTitle()+" "+d[i].getFolderName()+" "+d[i].getPages()); | ||
} | ||
} | ||
|
||
} | ||
public static Document[] docWithOddPages(Document[] d) | ||
{ | ||
Document[] st = new Document[0]; | ||
for(int i=0; i<d.length; i++) | ||
{ | ||
if(d[i].pages%2!=0) | ||
{ | ||
st = Arrays.copyOf(st,st.length+1); | ||
st[st.length-1]=d[i]; | ||
} | ||
} | ||
for(int i =0; i<st.length; i++) | ||
{ | ||
for(int j=i+1; j<st.length; j++) | ||
{ | ||
if(st[i].getId()>st[j].getId()) | ||
{ | ||
Document k=st[i]; | ||
st[i]=st[j]; | ||
st[j]=k; | ||
} | ||
} | ||
} | ||
if(st.length>0) | ||
{ | ||
return st; | ||
} | ||
else | ||
{ | ||
return null; | ||
} | ||
} | ||
} | ||
class Document | ||
{ | ||
int id; | ||
String title; | ||
String folderName; | ||
int pages; | ||
|
||
public Document(int id, String title, String folderName, int pages) | ||
{ | ||
this.id = id; | ||
this.title = title; | ||
this.folderName = folderName; | ||
this.pages = pages; | ||
} | ||
|
||
public int getId() | ||
{ | ||
return id; | ||
} | ||
public void setId(int id) | ||
{ | ||
this.id = id; | ||
} | ||
public String getTitle() | ||
{ | ||
return title; | ||
} | ||
public void setTitle(String title) | ||
{ | ||
this.title = title; | ||
} | ||
public String getFolderName() | ||
{ | ||
return folderName; | ||
} | ||
public void setFolderName(String folderName) | ||
{ | ||
this.folderName = folderName; | ||
} | ||
public int getPages() | ||
{ | ||
return pages; | ||
} | ||
public void setPages(int pages) | ||
{ | ||
this.pages = pages; | ||
} | ||
} |
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,75 @@ | ||
import java.util.*; | ||
|
||
public class IBM1 { | ||
public static void main(String[]args) | ||
{ | ||
Scanner sc = new Scanner(System.in); | ||
System.out.println("Enter number of rows : "); | ||
int row = sc.nextInt(); | ||
System.out.println("Enter number of columns : "); | ||
int col = sc.nextInt(); | ||
int[][] arr = new int[row][col]; | ||
for(int i =0 ; i<row; i++) | ||
{ | ||
for(int j=0; j<col; j++) | ||
{ | ||
arr[i][j]=sc.nextInt(); | ||
} | ||
} | ||
int p = Math.max(row,col); | ||
int[] dia1 = new int[p]; | ||
int[] dia2 = new int[p]; | ||
int[] dia = new int[p+p]; | ||
for(int i = 0; i<row; i++) | ||
{ | ||
for(int j=0; j<col; j++) | ||
{ | ||
if(i==j) | ||
{ | ||
dia1[i]=arr[i][j]; | ||
} | ||
} | ||
} | ||
for(int i = row-1; i>-1; i++) | ||
{ | ||
for(int j=0; j<col; j++) | ||
{ | ||
if(i==j) | ||
{ | ||
dia2[i]=arr[i][j]; | ||
} | ||
} | ||
} | ||
int count = 0, loop, num2=0; | ||
int num; | ||
for(int i=0; i<p; i++) | ||
{ | ||
dia[i]=dia1[i]; | ||
count++; | ||
} | ||
for(int i=0; i<p; i++) | ||
{ | ||
dia[count++]=dia2[i]; | ||
} | ||
for(int k = 0; k<(p+p); k++) | ||
{ | ||
loop=0; | ||
for(int i=2; i<dia[k]; i++) | ||
{ | ||
if(dia[k]%i==0) | ||
{ | ||
loop++; | ||
} | ||
} | ||
if(loop==0) | ||
{ | ||
num = dia[k]; | ||
} | ||
if( num > num2) | ||
{ | ||
num2 = num; | ||
} | ||
} | ||
System.out.println("Max Prime : "+num); | ||
} | ||
} |
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,27 @@ | ||
package Java; | ||
import java.util.*; | ||
public class IPA1 { | ||
public static void main(String[]args) | ||
{ | ||
int count=0; | ||
Scanner sc = new Scanner(System.in); | ||
int n = sc.nextInt(); | ||
while(n>0) | ||
{ | ||
int rem = n%10; | ||
if(rem%2==0) | ||
{ | ||
count++; | ||
} | ||
n = n/10; | ||
} | ||
if(count>=3) | ||
{ | ||
System.out.println("True"); | ||
} | ||
else | ||
{ | ||
System.out.print("False"); | ||
} | ||
} | ||
} |
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,19 @@ | ||
import java.util.*; | ||
public class IPA2 { | ||
public static void main(String[]args) | ||
{ | ||
int count = 0; | ||
Scanner sc = new Scanner(System.in); | ||
String s = sc.nextLine(); | ||
char[] arr; | ||
arr = s.toCharArray(); | ||
for(int i=0; i<arr.length;i++) | ||
{ | ||
if(Character.isLowerCase(arr[i])) | ||
{ | ||
count++; | ||
} | ||
} | ||
System.out.println(count); | ||
} | ||
} |
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,20 @@ | ||
package Java; | ||
import java.util.*; | ||
public class IPA2 { | ||
public static void main(String[]args) | ||
{ | ||
int count=0; | ||
Scanner sc = new Scanner(System.in); | ||
String s = sc.nextLine(); | ||
char[] arr; | ||
arr = s.toCharArray(); | ||
for(int i=0;i<arr.length;i++) | ||
{ | ||
if(Character.isLowerCase(arr[i])) | ||
{ | ||
count++; | ||
} | ||
} | ||
System.out.print(count); | ||
} | ||
} |
Oops, something went wrong.