Results 1 to 16 of 16
- 11-18-2009, 07:22 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 7
- Rep Power
- 0
- 11-18-2009, 07:27 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Input from where?
- 11-18-2009, 07:33 PM #3
Member
- Join Date
- Nov 2009
- Posts
- 7
- Rep Power
- 0
i will explain
for ex consider integer variables a,b
a='0x5a';
b=90;
here both are displays same values when print them
i want know the input of a is decimal or hexdecimal. input value is given by others it will not displays to the programer
- 11-18-2009, 07:40 PM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
With those quotes it won't compile at all.
If you remove the quotes then hexadecimals start with 0x or 0X.
- 11-18-2009, 07:47 PM #5
Both values get stored in the same form (4 bytes for integer; base 16) and represented as an integer when you display it on the screen or in your code (not a decimal number!).
Java Code:int a = 0xF3; int b = 243; System.out.println(a); if(a == b) System.out.println("Equivalant!"); if(0x000000F3 == 243) System.out.println("Equivalant!");Last edited by mrmatt1111; 11-18-2009 at 07:51 PM.
My Hobby Project: LegacyClone
- 11-18-2009, 07:50 PM #6
Member
- Join Date
- Nov 2009
- Posts
- 7
- Rep Power
- 0
my problem is that input is given by other programmer it is decimal or hexdecimal value .
i want to know that the given input value is decimal or hexdecimal. based on this i can solve the puzzle.
for ex he gives the input for integer variable is 0x5a it is hexdecimal value then i will divide it by rgb format and solve the puzzle.
if it is decimal it will be solved by another way
- 11-18-2009, 07:56 PM #7
as r035198x asked "Input from where?"
If you input is the form of a string you can do something like this:
Java Code:int value = 0; try { value = Integer.parseInt(input); //input is a string } catch(Exception e) { System.out.println("Not an Integer") }Last edited by mrmatt1111; 11-18-2009 at 07:59 PM.
My Hobby Project: LegacyClone
- 11-18-2009, 08:11 PM #8
Member
- Join Date
- Nov 2009
- Posts
- 7
- Rep Power
- 0
i will explain clearly
package test.blurimg;
public class BlurImage {
public image blur_image(image i, int radius) {
//Write your code here
return null;
}
// You could use this sample code to test your functions
// Following main fucntion contains 3 representative test cases
public static void main(String[] args) {
//TestCase 1
try {
image i = new image();
i.rows = 5;
i.columns = 3;
i.data = new int[][]{{6, 12, 18}, {5, 11, 17}, {4, 10, 16}, {3, 9, 15}, {2, 8, 14}};
BlurImage obj = new BlurImage();
image res = obj.blur_image(i, 2);
System.out.println("TestCase 1");
if (res != null) {
for (int k = 0; k < i.rows; k++) {
System.out.println();
for (int j = 0; j < i.columns; j++) {
System.out.print(res.data[k][j] + ",");
}
}
} else
System.out.println("NULL");
}
catch (Exception e) {
e.printStackTrace();
}
//TestCase 2
try {
image i = new image();
i.rows = 3;
i.columns = 5;
i.data = new int[][]{{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038}};
BlurImage obj = new BlurImage();
image res = obj.blur_image(i, 1);
System.out.println("\nTestCase 2");
if (res != null) {
for (int k = 0; k < i.rows; k++) {
System.out.println();
for (int j = 0; j < i.columns; j++) {
System.out.print(res.data[k][j] + ",");
}
}
} else
System.out.println("NULL");
}
catch (Exception e) {
e.printStackTrace();
}
//TestCase 3
try {
image i = new image();
i.rows = 3;
i.columns = 5;
i.data = new int[][]{{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038}};
BlurImage obj = new BlurImage();
image res = obj.blur_image(i, 4);
System.out.println("\nTestCase 3");
if (res != null) {
for (int k = 0; k < i.rows; k++) {
System.out.println();
for (int j = 0; j < i.columns; j++) {
System.out.print(res.data[k][j] + ",");
}
}
} else
System.out.println("NULL");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
this is my puzzle here i.data is input it contains both decimal and hexdecimal values
if i.data contains hexdecimal value it will converted into RGB format and solved.
otherwise i will solve by another way.
- 11-18-2009, 08:22 PM #9
You have to understand, whether you represent your value as a hexdecimal or an integer, it's real value is exactly the same. There is no way to know the difference because there is no difference.
My Hobby Project: LegacyClone
- 11-18-2009, 08:28 PM #10
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Where is the array data coming from?
Do you read it from a file? Do you receive it as an object or perhaps strings passed as program arguments?
This is the question that we have been asking and you have not answered.
- 11-18-2009, 08:29 PM #11
Member
- Join Date
- Nov 2009
- Posts
- 7
- Rep Power
- 0
if array contains hexdecimal value then it will in the form of RGB now i will divide it R,G,B and find the avg of r,g,b of surrounded values for a value.
if it is decimal i will find the avg of surrounded values for a value.
here i need to find out if array contains hexdecimal it will follow first case other wise second case
the solution for this puzzle will suitable for all input values like decimal and hexdecimal
- 11-18-2009, 08:34 PM #12
Member
- Join Date
- Nov 2009
- Posts
- 7
- Rep Power
- 0
here data is array of integers. they cannot allow using of strings.
we must follow the rules.
here we are using the given inputs only. i already posted them along with puzzle.
please refer them .
package test.blurimg;
public class image {
public int[][] data;
public int rows;
public int columns;
}
- 11-18-2009, 08:42 PM #13
Convert your input to a string and check with the subString method if it contains an 'x' or any letters 'a-f'
Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- 11-18-2009, 08:43 PM #14
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Then integers are just integers.
The values are the same.
This has already been said before but you continue to ignore it.
- 11-18-2009, 08:50 PM #15
Member
- Join Date
- Nov 2009
- Posts
- 7
- Rep Power
- 0
in my puzzle i am passing the object to a function . object contains array of integers .
once when i assign a hexdecimal value to integer it will convert into binary format.
when i was trying to convert it into string it will gives a decimal value even if we are assign the hexdecimal values. "we cannot change the inputs. it is rule for this contest"
- 11-18-2009, 09:01 PM #16
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
How to convert Integer[] to int[]
By Nithya in forum New To JavaReplies: 26Last Post: 02-11-2010, 05:41 PM -
Input technique for unknown lines of input
By ducreative in forum New To JavaReplies: 16Last Post: 09-23-2009, 09:26 AM -
input to an integer (simply)
By chitwood in forum Advanced JavaReplies: 3Last Post: 03-18-2009, 06:34 AM -
Integer vs int
By bugger in forum New To JavaReplies: 1Last Post: 11-14-2007, 09:13 PM -
how to take input and verify input in Java programs
By bilal_ali_java in forum Advanced JavaReplies: 0Last Post: 07-21-2007, 08:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks