J
jay'el antonio
please someone help me..what is the code of this output program using java
11
221
3321
44321
554321
6654321
77654321
887654321
11
221
3321
44321
554321
6654321
77654321
887654321
jay'el antonio said:please someone help me..what is the code of this output program using java
11
221
3321
44321
554321
6654321
77654321
887654321
public final class Mainjay'el antonio said:please someone help me..what is the code of this output program using java
11
221
3321
44321
554321
6654321
77654321
887654321
{ public static void main( final java.lang.String[] args )
{ java.lang.System.out.printf
( "11%n221%n3321%n44321%n554321%n6654321%n77654321%n887654321" ); }}
My new version corrects a mistake (a final »%n« was missing),
and takes into account the possible objection that the program
was intended to be written with two nested loops:
public final class Main
{ public static void main( final java.lang.String[] args )
{ while( args == null )while( args == null ); java.lang.System.out.printf
( "11%n221%n3321%n44321%n554321%n6654321%n77654321%n887654321%n" ); }}
please someone help me..what is the code of this output program using java
It is a pity that Java offers not so many code obfuscation techniques as
C++ does. I usually enjoy your C++ postings more (especially
(e-mail address removed), that was hilarious).
Joshua said:Snip
I disagree, here is some wonderful code obfuscation. Were I more
involved, I would have tried to find a better obfuscation than roman
numerals for the main string, but, with any luck, the OP is reading this
in a client with variable-width font and the text runs together as a
whole lot of I's.
public class Test {
public static void main(String... args) {
char[] K = new char[256];
int K = 0, Κ = 0;
char[] К = ("â… â… â… â… â… â… â… â… â…¢â…¢â…¢â…¢â…¢â…¢â…¤â…£â… â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¡â…¥â… â… â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¡â…¡â…¡â…¢â…¤â…£â… " +
"â…¢â… â…¢â…¡â…¡â…¥â… â… â…¦â…¡â…¤â… â…¦â…£â…¡â…£â…¥â… â… â…¦â…¡â…¡â…¡â…¢â…¢â…¤â…£â… â…¢â… â…¢â…¡â…¡â…¥â… â… â…¦â…¡â…¤â… â…¦â…£â…¡â…£â…¥â… â… â…¦â…¡â…¡â…¡â…¢â…¢â…¢â…¤â…£â… â…¢â… â…¢â…¡â…¡" +
"â…¥â… â… â…¦â…¡â…¤â… â…¦â…£â…¡â…£â…¥â… â… â…¦â…¡â…¡â…¡â…¢â…¢â…¢â…¢â…¤â…£â… â…¢â… â…¢â…¡â…¡â…¥â… â… â…¦â…¡â…¤â… â…¦â…£â…¡â…£â…¥â… â… â…¦â…¡â…¡â…¡â…¢â…¢â…¢â…¢â…¢â…¤â…£â… â…¢â… â…¢â…¡â…¡â…¥" +
"â… â… â…¦â…¡â…¤â… â…¦â…£â…¡â…£â…¥â… â… â…¦â…¡â…¡â…¡â…¢â…¢â…¢â…¢â…¢â…¢â…¤â…£â… â…¢â… â…¢â…¡â…¡â…¥â… â… â…¦â…¡â…¤â… â…¦â…£â…¡â…£â…¥â… â… â…¦â…¡â…¡â…¡â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¤â…£â… â…¢â… â…¢" +
"â…¡â…¡â…¥â… â… â…¦â…¡â…¤â… â…¦â…£â…¡â…£â…¥â… â… â…¦â…¡â…¡â…¡â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¢â…¤â…£â… â…¢â… â…¢â…¡â…¡â…¥â… â… â…¦â…¡â…¤â… â…¦â…£â…¡â…£â…¥â… â… â…¦â…¡â…¡â…¡").toCharArray();
int Ⲕ = К.length;
while (Κ < К.length) {
switch (К[Κ]) {
case 'â… ': K++; break;
case 'Ⅱ': K--; break;
case 'Ⅲ': K[K]++; break;
case 'Ⅳ': K[K]--; break;
case 'Ⅴ': Ⲕ = Κ; if (K[K] == 0) Κ = K(К, Κ); break;
case 'Ⅵ': Κ = Ⲕ - 1; break;
case 'Ⅶ': System.out.print(K[K]); break;
}
Κ++;
}
}
private static int K(char[] К, int Κ) {
int K = 0;
for (++Κ; Κ < К.length; Κ++) {
if (К[Κ] == 'Ⅴ') K++;
else if (К[Κ] == 'Ⅵ' && K-- == 0) return Κ;
}
return Κ;
}
}
At first, this code wouldn't run because for some reasons Thunderbird
treated the K in the lines
char[] K = new char[256];
and the first K in this line
int K = 0, Κ = 0;
both as 0x4B, thus making the code erroneous. Or maybe it was one of the
newsservers that made the substitution.
char[] K = new char[256];
int K = 0, Κ = 0;
I never knew that Java allowed Unicode letters in the source code, so I
even learned something new today.
either pasting from the clipboard to your IDE or your actual Java
compiler is doing some NFC normalization. I suppose you could
To prevent the dreaded clipboard normalization, I will from now on post
my source code in a way that will evade any clipboard normalization.
\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0063\u006c\u0061\u0073\u0073\u0020\u004d\u0061\u0069\u006e
\u007b\u0020\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0076\u006f\u0069\u0064\u0020\u006d\u0061\u0069\u006e\u0028\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u006a\u0061\u0076\u0061\u002e\u006c\u0061\u006e\u0067\u002e\u0053\u0074\u0072\u0069\u006e\u0067\u005b\u005d\u0020\u0061\u0072\u0067\u0073\u0020\u0029
\u0020\u0020\u007b\u0020\u0077\u0068\u0069\u006c\u0065\u0028\u0020\u0061\u0072\u0067\u0073\u0020\u003d\u003d\u0020\u006e\u0075\u006c\u006c\u0020\u0029\u0077\u0068\u0069\u006c\u0065\u0028\u0020\u0061\u0072\u0067\u0073\u0020\u003d\u003d\u0020\u006e\u0075\u006c\u006c\u0020\u0029\u003b\u0020\u006a\u0061\u0076\u0061\u002e\u006c\u0061\u006e\u0067\u002e\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u006f\u0075\u0074\u002e\u0070\u0072\u0069\u006e\u0074\u0066
\u0020\u0020\u0020\u0020\u0028\u0020\u0022\u0031\u0031\u0025\u006e\u0032\u0032\u0031\u0025\u006e\u0033\u0033\u0032\u0031\u0025\u006e\u0034\u0034\u0033\u0032\u0031\u0025\u006e\u0035\u0035\u0034\u0033\u0032\u0031\u0025\u006e\u0036\u0036\u0035\u0034\u0033\u0032\u0031\u0025\u006e\u0037\u0037\u0036\u0035\u0034\u0033\u0032\u0031\u0025\u006e\u0038\u0038\u0037\u0036\u0035\u0034\u0033\u0032\u0031\u0025\u006e\u0022\u0020\u0029\u003b\u0020\u007d\u007d
Stuart <[email protected]> said:My new version corrects a mistake (a final »%n« was missing),
and takes into account the possible objection that the program
was intended to be written with two nested loops:
public final class Main
{ public static void main( final java.lang.String[] args )
{ while( args == null )while( args == null ); java.lang.System.out.printf
( "11%n221%n3321%n44321%n554321%n6654321%n77654321%n887654321%n" ); }}
I was going to ask you whether you have some kind of archive for FAHQ,
but this proves that these gems are hand-crafted on the fly. Nice job, too.
It is a pity that Java offers not so many code obfuscation techniques as
C++ does. I usually enjoy your C++ postings more (especially
(e-mail address removed), that was hilarious).
Regards,
Stuart
lipska said:Well. Now that everyone has had the obligatory attempt at being a
smartarse and, hopefully, you have had time to figure this out for
yourself, try this. There are some possible 'optimizations' depending on
you view regarding 'unnecessary' variables and hard-coded magic numbers.
I'm sure some of the smartarses will offer their invaluable advice in
this area.
Absolutely.
public class AntiSmartArseClass {
public static void main(String[] args) {
int increment = 11;
int iterations = 8;
int outerindex = 1;
int innerindex= 0;
while(outerindex <= iterations){
Yep.
System.out.printf("%d", outerindex * increment);
innerindex = (outerindex * increment) % 10;
while(innerindex > 1){
System.out.printf("%d", --innerindex);
}
outerindex++;
System.out.println();
}
}
}
lipska said:public static void main(String[] args) {
int increment = 11;
This would be better as a constant.
Well firstly, you buffoon, although const *is* a reserved word in Java
it is not currently used, do you mean final? We have been down this road
soooooo many time before in here haven't we?
please someone help me..what is the code of this output program using
java
11
221
3321
44321
554321
6654321
77654321
887654321
Well. Now that everyone has had the obligatory attempt at being a
smartarse and, hopefully, you have had time to figure this out for
yourself, try this. There are some possible 'optimizations' depending on
you view regarding 'unnecessary' variables and hard-coded magic numbers.
I'm sure some of the smartarses will offer their invaluable advice in
this area.
public class AntiSmartArseClass {
public static void main(String[] args) {
int increment = 11;
int iterations = 8;
int outerindex = 1;
int innerindex= 0;
while(outerindex <= iterations){
System.out.printf("%d", outerindex * increment);
innerindex = (outerindex * increment) % 10;
while(innerindex > 1){
System.out.printf("%d", --innerindex);
}
outerindex++;
System.out.println();
}
}
}
The variable concerned has block scope within main.
You cannot apply the static modifier here.
static final int increment = 11;
my compiler says no with
Illegal modifier for parameter increment only final is permitted
So, you *could say*
final int increment
however this is not a constant because it's (potential) value is not
known at the time of declaration, at this point it is a 'variable'
later you can say (for example)
increment = Integer.parseInt(args[1]);
Now it's a final int but not a constant according to you via apparently
the JLS and 'normal Java terminology'
You could increase the visibility of increment to class scope, then you
*can* say
static final int increment = 11;
but you can also say
static final int increment;
increment is not a constant, it's an uninitialized static final int,
there's a difference.
You can then say
increment = 11;
However this would make the scope of increment wider which is another
Bloch no no.
Obviously I can't prove the following in Java as the reserved word const
is unused so I'll use C
So then Arne, how exactly would you make the variable increment constant
within main using your own criteria of a 'constant' in Java being static
final.
As always I'll be delighted to be shown how wrong I am.
lipska the kat said:You are a Troll, sans Hunter.
Yes of course. Anyone who doesn't think like you is a troll. Obviously.
You also made that far more complicated
than it needs to be.
public class BetterThanATroll {
public static void main(String[] args) {
String s = "";
for (int i = 1; i <= 8; ++i) {
s = i + s;
System.out.println(i + s);
}
}
}
Now that we've given the OP the answer to his homework, I hope he finds
a job working with you rather than with me.
I'm prepared to give anyone the benefit of the doubt ... once. Unlike you
apparently. Fortunately I no longer have to work with people who are so far up
themselves they can see the sky. I can pick and choose my projects and my
colleagues, I doubt you'd make it past the reception desk.
lipska the kat said:You are a Troll, sans Hunter. You also made that far more complicated
than it needs to be.
public class BetterThanATroll {
public static void main(String[] args) {
String s = "";
for (int i = 1; i <= 8; ++i) {
s = i + s;
System.out.println(i + s);
}
}
}
Well now let's analyze your 'solution' shall we.
Agreed the 'specification' is a little lacking but as we are unable to go back
to the client at this time we need to make some assumptions.
Assumption 1. It's 'homework'
OK, now what do you imagine the learning objectives are?
Well it certainly looks 'loopy' so
Assumption 2. It's intended to get the student to learn about loop control
variables, possibly to control nested loops.
The output is numeric so
Assumption 3. It's intended to exercise some understanding of manipulation of
numeric variables ...
Well that's about it for the assumptions, now how does your solution meet the
objectives?
... ah yes, String concatenation in a for loop
1/10 for effort
What, are you lipska's alter ego?lipska the kat said:On 2/23/14 1:25 AM, lipska the kat wrote:
On 21/02/14 00:03, jay'el antonio wrote:
please someone help me..what is the code of this output program using
java
11
221
3321
44321
554321
6654321
77654321
887654321
You are a Troll, sans Hunter. You also made that far more complicated
than it needs to be.
public class BetterThanATroll {
public static void main(String[] args) {
String s = "";
for (int i = 1; i <= 8; ++i) {
s = i + s;
System.out.println(i + s);
}
}
}
Well now let's analyze your 'solution' shall we.
Agreed the 'specification' is a little lacking but as we are unable to go back
to the client at this time we need to make some assumptions.
Assumption 1. It's 'homework'
OK, now what do you imagine the learning objectives are?
Well it certainly looks 'loopy' so
Assumption 2. It's intended to get the student to learn about loop control
variables, possibly to control nested loops.
The output is numeric so
Assumption 3. It's intended to exercise some understanding of manipulation of
numeric variables ...
Well that's about it for the assumptions, now how does your solution meet the
objectives?
... ah yes, String concatenation in a for loop
1/10 for effort
Nicely done. Why is that Java groups and IRC channels in particular are
so full of self inflated pompous idiots who seem to be there only to
belittle others and demonstrate their inate stupidity and narrow
mindedness?
Hmm, perhaps it is, but that is an assumption. Notice the "Ass" and "U"You are a Troll, sans Hunter. You also made that far more complicated
than it needs to be.
public class BetterThanATroll {
public static void main(String[] args) {
String s = "";
for (int i = 1; i <= 8; ++i) {
s = i + s;
System.out.println(i + s);
}
}
}
Well now let's analyze your 'solution' shall we.
Agreed the 'specification' is a little lacking but as we are unable to
go back to the client at this time we need to make some assumptions.
Assumption 1. It's 'homework'
OK, now what do you imagine the learning objectives are?
Well it certainly looks 'loopy' so
Assumption 2. It's intended to get the student to learn about loop
control variables, possibly to control nested loops.
So you're going to throw in modules arithmetic, number theory, multipleThe output is numeric so
Assumption 3. It's intended to exercise some understanding of
manipulation of numeric variables ...
Ultimate learning objective: Do things the simplest possible way.Well that's about it for the assumptions, now how does your solution
meet the objectives?
... ah yes, String concatenation in a for loop
1/10 for effort
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.