  C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # How to solve this exercise using for-loop?  » java » How to solve this exercise using for-loop?

By : gabriel
Date : November 18 2020, 11:13 AM
around this issue How do you solve this using for loop? and which is more better, for loop or just lastIndexOf? , In Case you need a for loop you can go with the below code. code :
`````` public static boolean check(String s1,String s2)
{
boolean result = false;

if(s1.length() >= s2.length())
{
result = compare(s1, s2);
}
else
{
result = compare(s2,s1);
}

return  result;
}

public static boolean compare(String s1,String s2)
{
boolean result = false;
char[] array1 = s1.toCharArray();
char[] array2 = s2.toCharArray();
if(array1.length>=array2.length)
{
int j = array2.length-1;
for(int i = array1.length-1;i>=0;i--,j--)
{
if(j==0)
{
if(!(array1[i]==array2[j]))
{
break;
}
else
{
result = true;
break;
}
}
else
{
if(!(array1[i]==array2[j]))
{
break;
}
}
}
}

return result;

}
`````` ## How would I solve this SQL exercise?

By : qqt
Date : March 29 2020, 07:55 AM
should help you out You could use the replace function to remove the zeros, and then just subtract the two averages:
code :
``````SELECT AVG(salary) - AVG(REPLACE(salary, '0', '')) AS mistake
FROM   employees
`````` ## How to solve this for-loop exercise in c++ (beginner). n + nx2 + nx2x2 +

By : Amna Sulaiman
Date : March 29 2020, 07:55 AM
I hope this helps . I was trying to write a c++ programm, which begins with int a - 5 items, and every second int b - gets bigger 2x times. For example 1second prints - 5, 2second - 10, 3second - 20. And then print a sum of it. (35). Since I'm a very beginner, got stuck with it.
code :
``````#include <iostream>
using namespace std;

int main()

{
int a,b,i,result;
cout << " Enter a and b: " << endl;
cin >> a >> b;
result = a;                 // At 0 sec result is a
for (i=1; i<=b; i++)
{
result = result*2;      // Doubles the result at every second
cout <<result<< endl;
}
return 0;
}
`````` ## SQL Exercise - Can't seem to solve this

By : Deepak Patil
Date : March 29 2020, 07:55 AM
Any of those help I'm pretty new to writing SQL queries manually, and I have an exercise which I can't seem to solve. , You may use for example NOT EXISTS
code :
``````select distinct w1.eid
from Project p1
join workson w1 on p1.pid = w1.pid
where not exists(
select 1
from Project p2
join workson w2 on p2.pid = w2.pid
where w1.eid = w2.eid and p2.pname != p1.pname
)
``````
``````select w.eid
from Project p
join workson w on p.pid = w.pid
group by w.eid
having count(distinct p.pname) = 1
`````` ## How to solve this exercise?

By : itee
Date : March 29 2020, 07:55 AM
Any of those help Are you just interested in a smooth line in the plot or are you looking for smoothed values?
If you're just after plotting, you could use the geom_smooth function:
code :
``````ggplot(txhousing, aes(date, rel_sales)) +
geom_line(aes(group = city), alpha = 1/5) +
geom_smooth(stat = "smooth", colour = "red", method="auto")
``````
``````ggplot(txhousing, aes(date, rel_sales)) +
geom_line(aes(group = city), alpha = 1/5) +
geom_smooth(method = "lm", formula = y ~ splines::bs(x, df = 15, degree = 3), se = FALSE)
`````` ## More efficient way to solve a Ruby exercise asking for the return of 2 indices, without using nested loop?

By : Hung Cheng
Date : March 29 2020, 07:55 AM
it should still fix some issue Sorry if the title was not clear. I have a problem that is solved, but I was hoping for insight into how to solve without using nested loop or if there was a more efficient method. ! , You could do the following. 