0
I have a query.
Are we allowed to use .split(""), Arrays.sort() , toCharArray() in the computer practical ?!and will this solution be accepted? QUESTION 8!
import java.io.*;
import java.util.*;
public class Cyclic_Number
{
public void main()
{
Scanner in=new Scanner(System.in);
System.out.print("ENTER NUMBER => ");
int n=in.nextInt(),i,len;
String str=Integer.toString(n);
String arr1[]=str.split("");
len=str.length();
Arrays.sort(arr1);
String compare=toString(arr1);
for(i=2;i<=len;i++)
{
String arr2[]=Integer.toString(n*i).split("");
Arrays.sort(arr2);
if(!compare.equals(toString(arr2)))
break;
}
if(i==len+1)
System.out.println(n+" IS A CYCLIC NUMBER");
else
System.out.println(n+" IS NOT A CYCLIC NUMBER");
}
public String toString (String arr[])
{
String str="";
for(int i=0;i<arr.length;i++)
str+=arr[i];
return str;
}
}
Are we allowed to use .split(""), Arrays.sort() , toCharArray() in the computer practical ?!and will this solution be accepted? QUESTION 8!
import java.io.*;
import java.util.*;
public class Cyclic_Number
{
public void main()
{
Scanner in=new Scanner(System.in);
System.out.print("ENTER NUMBER => ");
int n=in.nextInt(),i,len;
String str=Integer.toString(n);
String arr1[]=str.split("");
len=str.length();
Arrays.sort(arr1);
String compare=toString(arr1);
for(i=2;i<=len;i++)
{
String arr2[]=Integer.toString(n*i).split("");
Arrays.sort(arr2);
if(!compare.equals(toString(arr2)))
break;
}
if(i==len+1)
System.out.println(n+" IS A CYCLIC NUMBER");
else
System.out.println(n+" IS NOT A CYCLIC NUMBER");
}
public String toString (String arr[])
{
String str="";
for(int i=0;i<arr.length;i++)
str+=arr[i];
return str;
}
}
Aayush1994doon
Feb 10, '13
1 answers
1
You can use any valid function or class that is available in Java provided it's not deprecated. To the best of my knowledge, as long as have a working logic, it doesn't matter which functions you use in practical examination. However, be vary of their use in theory papers as the examiner might not be aware of the function you are using and it may go against you.
khanmansoor
Feb 10, '13
Log in to your account to answer this questions.