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
141e528
commit 2a08749
Showing
4 changed files
with
115 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,47 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* | ||
* @author SPREEHA DUTTA | ||
*/ | ||
import java.util.*; | ||
public class anagrams { | ||
public static String sort(String s) | ||
{ | ||
char arr[]=s.toCharArray(); | ||
char b; | ||
for(int i=0;i<arr.length;i++) | ||
{ | ||
for(int j=1;j<arr.length-i;j++) | ||
{ | ||
if(arr[j]<arr[j-1]) | ||
{ | ||
b=arr[j]; | ||
arr[j]=arr[j-1]; | ||
arr[j-1]=b; | ||
} | ||
} | ||
} | ||
s=new String(arr); | ||
return s; | ||
} | ||
public static void main(String []args) | ||
{ | ||
String s1,s2; | ||
Scanner sc=new Scanner(System.in); | ||
System.out.println("Enter two strings "); | ||
s1=sc.next(); | ||
s2=sc.next(); | ||
s1=sort(s1); | ||
s2=sort(s2); | ||
if(s1.equals(s2)) | ||
System.out.println("They are anagrams"); | ||
else | ||
System.out.println("They are not anagrams"); | ||
} | ||
} |
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 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* | ||
* @author SPREEHA DUTTA | ||
*/ | ||
import java.util.*; | ||
public class capitalise { | ||
public static void main(String []args) | ||
{ | ||
String s;int i,j;char b;String str=""; | ||
Scanner sc=new Scanner(System.in); | ||
System.out.println("Enter a string"); | ||
s=sc.nextLine(); | ||
String arr[]=s.split(" "); | ||
for(i=0;i<arr.length;i++) | ||
{ | ||
str=""; | ||
for(j=0;j<arr[i].length();j++) | ||
{ | ||
b=arr[i].charAt(j); | ||
if(j==0) | ||
b=Character.toUpperCase(b); | ||
str=str+b; | ||
} | ||
System.out.print(str+" "); | ||
} | ||
} | ||
} |
Submodule dailycodebase
added at
5462d0
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,33 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* | ||
* @author SPREEHA DUTTA | ||
*/ | ||
import java.util.*; | ||
public class reverse_word { | ||
public static void main(String []args) | ||
{ | ||
Scanner sc=new Scanner(System.in); | ||
String s;int i,j;String str="";char b; | ||
|
||
System.out.println("Enter a string "); | ||
s=sc.nextLine(); | ||
String arr[]=s.split(" "); | ||
for(i=0;i<arr.length;i++) | ||
{ | ||
str=""; | ||
for(j=0;j<arr[i].length();j++) | ||
{ | ||
b=arr[i].charAt(j); | ||
str=b+str; | ||
} | ||
System.out.print(str+" "); | ||
} | ||
} | ||
} |