Two or more solutions:
//Solution 1: call-by-reference function parameter using
// ampersand sign &
void swap_values(int& variable1, int& variable2)
{
int temp;
temp = variable1;
variable1 = variable2;
variable2 = temp;
}
//Solution 2: call-by-reference function parameter using
// asterisk sign * or pointer syntax
void swap_values_asterisk(int *variable1, int *variable2)
{
int temp;
temp = *variable1;
*variable1 = *variable2;
*variable2 = temp;
}
//Solution 3: call-by-reference function parameter using
// a standard library function, put inside driver
void swap_values_stdLibraryFunction(int& variable1, int& variable2)
{
swap(variable1, variable2); //put inside driver
}
//Solution 4: call-by-reference function parameter using array syntax
void swap_values_array(int array1[], int array2[])
{
int temp;
temp = array1[0];
array1[0] = array2[0];
array2[0] = temp;
}
Driver:
int a, b;
a=1;
b=2;
swap_values(a, b);
cout << "a: " << a << ", b: " << b << endl;
a=1;
b=2;
swap_values_asterisk(&a, &b);
cout << "a: " << a << ", b: " << b << endl;
a=1;
b=2;
swap_values_stdLibraryFunction(a, b);
cout << "a: " << a << ", b: " << b << endl;
int array_a[10];
int array_b[10];
array_a[0] = 1;
array_b[0] = 2;
swap_values_array(array_a, array_b);
cout << "a: " << array_a[0] << ", b: " << array_b[0] << endl;
Program output:
a: 2, b: 1
a: 2, b: 1
a: 2, b: 1
a: 2, b: 1
Reading. Practice. Writing.
Please feel free to comment. Suggestions are also welcomed here. Write something "wholesome serving purpose" here.
Monday
C++ using Boost Library: How do I tokenize words from a string in C++?
C++ using Boost Library: How do I tokenize words from a string in C++?
Source Code:
#include <boost/algorithm/string.hpp>
vector<string> vec_str;
boost::split(vec_str, "word0 word1 word2", boost::is_space());
for(size_t i=0; i<vec_str.size(); ++i)
{
cout << "vec_str[" << i << "] = " << vec_str[i] << endl;
}
Output:
vec_str[0] = word0
vec_str[1] = word1
vec_str[2] = word2
Thursday
Getting Started with Eclipse IDE 64-bit Neon and Java 8 Programming
Download and install Java SE JDK 8 64-bit
of filename jdk-8u121-windows-x64.exe
from
Download Eclipse IDE 64-bit Neon
of filename eclipse-java-neon-3-win32-x86_64.zip
from
Note: Download Eclipse in zip file format because no installation is required. Do not download the eclipse-inst-win64.exe executable file.
Copy the downloaded zip file eclipse-java-neon-3-win32-x86_64.zip to C drive
Extract the zip file to C drive. You do not need to install this file. The zip file is not the executable file.
Right-click at
C:\eclipse-java-neon-3-win32-x86_64\eclipse\eclipse.exe
Select “Send to” > select “Desktop (create shortcut)”
Rename the shortcut file as “eclipse-java-neon-3-win32-x86_64”
On the desktop, double-click the eclipse desktop icon shortcut
of shortcut name “eclipse-java-neon-3-win32-x86_64”
Create and Select a directory as workspace at
Workspace: D:\workspace_eclipse
Close the Welcome screen
Eclipse IDE Menu > File > New > Java Project
Project Name: projectTest1
Click the button Finish
Go to Package Explorer window
Right-click on the “src” folder > select New > select Class
On the Java Class window: Java filename: Name: Class1
Click the button Finish
Filename: Class1.java
Type the following file content:
///// ///// ///// /////
package projectTest1;
public class Class1 {
public static void main(String[] args) {
System.out.println("hello world");
}
}
///// ///// ///// /////
Toolbar > Play button
See the program output in the console window.
///// ///// ///// /////
hello world
///// ///// ///// /////
Android Mobile Phone has Three Buttons instead of only One Home Button for Productivity
At the bottom part of an Android mobile phone, you can see that there are three buttons. The three buttons are the Back button, the Home button and the Recent Apps button as shown below.
+--------+--------+---------+
| Back | Home | Recent |
| | | Apps |
+--------+--------+---------+
With three buttons instead of only one middle Home button, you have more customizable actions to play with.
The Back button should be at the leftmost just like the back button on the web browser toolbar. The Home button will take you to the home screen by tapping one time on it. The Recent Apps button at the bottom rightmost of the mobile phone displays the most recently opened apps.
Monday
How to Install Steam to Play Dota 2 Game on Linux Mint
You can play many popular games such as Dota 2 on Linux Mint.
Dota 2 is a free-to-play multiplayer online battle arena (MOBA) video game developed and published by Valve Corporation. The Dota 2 game is the stand-alone sequel to Defense of the Ancients (DotA). One of the main objectives of the game is to be the first to destroy a huge structure located at the enemy base called the “Ancient”.
To play other games such as as “Counter-Strike: Global Offensive (CS: GO)”, you will have to make online payment using debit MasterCard or debit Visa card beforehand.
Do the following steps:
Start Menu > Administration > Terminal
Type
$ sudo apt-get update
Wait for some time to update your operating system
Type
$ sudo apt-get install steam
Wait for some time and follow on-screen instructions to install Steam program
Start Menu > Games > Steam
Click on the Store tab
Search for "Dota 2" in the online Store
Select “Dota 2” game
Click on the button "Get Dota 2"
Wait for some time to download “Dota 2” game
Install the “Dota 2” game
Start Menu > Games > Dota 2
For player who is new to the Dota 2 game, you should start by playing the “Learn section”
in order to have a basic understanding of the game. There are six tutorials for you to learn. They are Mechanics, Dragon Knight, Sniper, Shadow Shaman, Co-op Match, and Multiplayer Match.
Enjoy choosing and playing the game that you love.
Dota 2 is a free-to-play multiplayer online battle arena (MOBA) video game developed and published by Valve Corporation. The Dota 2 game is the stand-alone sequel to Defense of the Ancients (DotA). One of the main objectives of the game is to be the first to destroy a huge structure located at the enemy base called the “Ancient”.
To play other games such as as “Counter-Strike: Global Offensive (CS: GO)”, you will have to make online payment using debit MasterCard or debit Visa card beforehand.
Do the following steps:
Start Menu > Administration > Terminal
Type
$ sudo apt-get update
Wait for some time to update your operating system
Type
$ sudo apt-get install steam
Wait for some time and follow on-screen instructions to install Steam program
Start Menu > Games > Steam
Click on the Store tab
Search for "Dota 2" in the online Store
Select “Dota 2” game
Click on the button "Get Dota 2"
Wait for some time to download “Dota 2” game
Install the “Dota 2” game
Start Menu > Games > Dota 2
For player who is new to the Dota 2 game, you should start by playing the “Learn section”
in order to have a basic understanding of the game. There are six tutorials for you to learn. They are Mechanics, Dragon Knight, Sniper, Shadow Shaman, Co-op Match, and Multiplayer Match.
Enjoy choosing and playing the game that you love.
Subscribe to:
Posts (Atom)
If a hater attacked your age and not the goodness of you
Whether young or old, I've always been known what endures. I've known the very idea of people that were all created equal and deserv...
-
DiGi Super Long Life is a feature where you can extend your talktime validity to 1 year for just RM38. Indirectly, the subscription fee is ...
-
Open LibreOffice Draw program. Select the rectangle shape from shape toolbar at the bottom of drawing page. Click a point and drag-and-re...
-
DiGi Super Long Life is a feature where you can extend your talktime validity to 1 year for just RM30. Indirectly, the subscription fee is...