[Solved] How do I replace a line in a file using Perl?

The only actual problem with your code was that you were printing the line to the new file in the wrong place in the loop. You need to print every line from the old file into the new file. Having tidied your file a little and updated some of the idioms, I end up with … Read more

[Solved] Does anybody tell me what changes need to be done here if I want a triangle at the top not bottom?

Basically you need to change the positions of the various gradients. The first one’s vertical position should start at the “arrow width” var. Both the others vertical positions should be set to 0 instead of 100%. You also need to change the direction of the last two gradients from “to top” to “to bottom” so … Read more

[Solved] What is the advantage of passing by reference to shared_ptr over passing by reference directly

The only reason a function should accept a std::shared_ptr as a argument is if it may need to share or modify the ownership of the resource. If not, don’t pass a std::shared_ptr. If the function will definitely need to take shared ownership then it should accept a std::shared_ptr by value. Only accept a std::shared_ptr& if … Read more

[Solved] User-enter values are not being stored properly

while ( choice != -1 ) { System.out.println( “Enter a homework grade. Press -1 when finished” ); homework = dylan.nextInt(); } This loop will never exit, because the user’s entry is put into homework, but you’re testing choice in the while loop. The fix: while ( homework != -1 ) { System.out.println( “Enter a homework … Read more

[Solved] how to check if a second has elapsed c++

In C++11, you can use std::this_thread::sleep_for() to get your program (well, the current thread, strictly speaking) to pause for approximately the length of time you specify. For example: #include <chrono> #include <thread> using namespace std::chrono_literals; int main() { int variable = 0; while (variable < 10) { std::this_thread::sleep_for(1s); // sleep for one second ++variable; } … Read more

[Solved] I am trying to create a sql table in phpmyadmin, I’m getting 4 errors. This code works in phpmyadmin on my pc at my work but not on the pc at home [closed]

I am trying to create a sql table in phpmyadmin, I’m getting 4 errors. This code works in phpmyadmin on my pc at my work but not on the pc at home [closed] solved I am trying to create a sql table in phpmyadmin, I’m getting 4 errors. This code works in phpmyadmin on my … Read more

[Solved] Use a 2-D matrix to represent data [closed]

I think this code will work: String arr[][]=new String[4][4]; //For reading name of Cold Drink System.out.println(“ENTER NAME OF COLD DRINKS”); for(int r=1;r<4;r++) arr[r][0]=sc.nextLine(); //For reading name of Cities System.out.println(“ENTER NAME OF CITIES”); for(int c=1;c<4;c++) arr[0][c]=sc.nextLine(); //For reading sales value for(int r=1;r<4;r++) { for(int c=1;c<4;c++) { System.out.println(“ENTER SALES VALUE OF ” + arr[r][0] + ” IN … Read more

[Solved] I need some help on this code [closed]

I’ve added some comments to your ifs to explain them // Extra post classes $PHTclasses = array(); // if iterator is evenly divisible by # columns, or if there is only one column, add “first” if ( 0 === ($woocommerce_loop[‘loop’]) % $woocommerce_loop[‘columns’] || 1 === $woocommerce_loop[‘columns’] ) $PHTclasses[] = ‘first’; // if iterator is evenly … Read more

[Solved] Checking if TableView row was selected for the first time

You can maintain a set like this. var selectedOnce = Set<Int>() Add the selected index to this set whenever it is selected first time. selectedOnce.insert(index) Check next time, whether it was already selected like if selectedOnce.contains(indexToCheck) { } If something is required for one time per app. I mean, it should not happen for next … Read more

[Solved] Unity3D transform like mirror?

Put an empty gameobject at the bottom of your screen. Add a collider(Box collider can do) to it and make it isTrigger and position it just below your screen. Write a code and add it to that empty gameObject with collider to check if any of your object is interacting that collider. void OnTriggerEnter() if(other.gameObject.tag … Read more