Provide me with some very hard program for a good mental workout and practice.
Please ,
I am providing u with one and u too please provide me some:
Take a 10 elements integer array.
Accept numbers in it from the user which can be negative or positive in the cells.
Now shift the positive numbers on the left side and the negative numbers on the right side in the same sequence as they are been provided in the array by the user.]
Now print the modified array.
Sample Input:{1,-1,2,-2,3,-3,4,-4,5,-5}
Sample Output:{1,2,3,4,5,-1,-2,-3,-4,-5}
(Note that the output can not have the sequence of the positive or negative numbers altered like the output cannot be {2,3,1,5,4,-1,-5,-3,-2,-4})
To make things a bit tough(the way my teacher made it) only 1 array can be used in the entire program.
No problem as it will never come at least in ICSE boards.
Share your tough program problems too please |
|
+ 3 more questions by rishidc
Aim at the stars even if you fail you will land on the moon(or an alien planet or white hole or whatever you like). |
|
asked by Rishi dey chowdhury (rishidc) 6 years ago |
0 |
The bodyless loop whose function in the book is given that"It is used to create delay" is actually not taken as a delay for humans as the i9 7980x processor overclocked at 4.6GHz processes it so quickly that hardly i can see any delay
but if you actually want a delay u can use
Thread.sleep(1000);//here 1000 means 1 second delay
time is given inside the brackets is in milli-seconds
but whenever u use it dont forget to wrap this function with try-catch block
try{
Thread.sleep(1000);
}
catch(InterruptedException e){
System.ot.println("Technical Problem");
}
NOTE:Strictly not for exam purpose |
|
asked by Rishi dey chowdhury (rishidc) 6 years ago |
3 |
Oh! I have a trick for arrays too.
lets assume we have an array named arr
then
for(i:arr)
{
System.out.println(i);//Here i have just printed the elements but you can do anything
}
//Here each time when the loop runs the i contains the next element of the array cell
which means if arr[] would be{1,7,10,99,-10}
i will have the value 1 in first execution of the for loop
then i will have value 7 in next loop and so on....
comment if you liked?
NOTE:Strictly not for exam purpose |
|
asked by Rishi dey chowdhury (rishidc) 6 years ago |
3 |
Catch on to fire if you must,sometimes everything needs to burn to the ground so that we may grow. |
|
asked by Pranav Ajinkya (narutorocks7) 6 years ago |
2 |
into x=2,y=50;
do
{
++x;
y=y-x++;
}while(x<=10);
return y; |
|
asked by Abhinav Sharma (monstercat) 6 years ago |
1 | + 1 more questions by monstercat
into m,n,p,q= 0;
for(m=2;m<=3;++m)
{
for(n=1;n<=m;++n)
{
p=m+n;
if(p%3==0)
q=q+p;
else
q=p+4;
}
}
System.out.println("Q="+q); |
|
asked by Abhinav Sharma (monstercat) 6 years ago |
1 |
|
I recently realized that 'System.out.println()' is a great example of function overloading. |
|
asked by Shreyas Minocha (shreyasminocha) 6 years ago |
3 | + 2 more questions by shreyasminocha
To get a random integer in the range [min, max),
int randomInt(int min, int max) {
return Math.floor(min + (Math.random() * (max - min)));
}
To get a random double in range [min, max):
double randomDouble(int min, int max) {
return min + (Math.random() * (max - min));
} |
|
asked by Shreyas Minocha (shreyasminocha) 6 years ago |
1 |
In how much time do you plan to complete your Computer paper's section A? |
|
asked by Shreyas Minocha (shreyasminocha) 6 years ago |
2 |
What's the use of static guys? |
|
asked by Leander Vikram (eldiablo0829) 6 years ago |
3 |
guys watch this till end i assure u it will not waste ur time
https://www.youtube.com/watch?v=dqTTojTija8 |
|
asked by Rtstud (mdarfath) 6 years ago |
2 | + 2 more questions by mdarfath
ok for patteren like this
i
ic
ics
icse
we normally use two for loops but there is shor cut . here it is
String nm = "icse";
for (int i = 1 ; i<=nm.length();i++)
s.o.p(nm.substring(0,1)); |
|
asked by Rtstud (mdarfath) 6 years ago |
6 |
Do we need to learn the randes of data value like 0-38924789 this crppy table wich is present in tb |
|
asked by Rtstud (mdarfath) 6 years ago |
1 |
Not exam related:
Does anyone watch South Park? |
|
asked by Pavan K Srinivasan (throwaway) 6 years ago |
0 |
Guys all of you must have faced the problem of printing a particular array as it requires the user to type out another for loop which is time consuming tedious and boring
heres a trick but u ll have to import java's utilility package by import java.util.*
just say u wanna print array named arr
type :- System.out.println(Arrays.toString(arr));
the output is like this : [a,b,c,d] try this one out |
|
asked by ⚡The Flash⚡ (devanshu8) 6 years ago |
2 |
| | |