Chapter 1: I Have Crossed Over! The Spiritual Root in My Dantian – An Introduction to Variables and Types
Liuyuyan is a middle school student who loves programming. She has already won the first prize in the second round of the CSP-S competition. One night, she discovered a strange program that looked ordinary:
#include<iostream>
using namespace std;
int main() {
int portal[3][3] = { // Ancient teleportation array matrix
{4, 9, 2},
{3, 5, 7},
{8, 1, 6}
};
int magic_number = 15; // The magic number of the teleportation array
bool is_activated = true;
for (int i = 0; i < 3; i++) {
int row_sum = 0, col_sum = 0;
for (int j = 0; j < 3; j++) {
row_sum += portal[i][j];
col_sum += portal[j][i];
}
if (row_sum != magic_number || col_sum != magic_number) {
is_activated = false;
break;
}
}
if (is_activated) {
cout << "The teleportation array has been activated!" << endl;
} else {
cout << "Teleportation array activation failed..." << endl;
}
return 0;
}
“What a strange program, it seems to be verifying an ancient teleportation array,” Liuyuyan muttered to herself. “Who is joking with me? A teleportation array?”
Out of curiosity, Liuyuyan decided to run the program herself. The moment she pressed the Enter key, the screen suddenly erupted with blinding light!
After a moment of dizziness, Liuyuyan found herself lying on a slab of bluestone, surrounded by swirling clouds. In the distance, the sound of a melodious bell echoed, and a majestic fairy mountain appeared faintly.
“Where is this?” Liuyuyan rubbed her eyes, just a moment ago she was debugging a C++ program in front of her computer, how did she end up in this ancient place in the blink of an eye?
Suddenly, a bolt of lightning struck from the sky, heading straight for Liuyuyan! She closed her eyes in terror, but felt her body wrapped in a warm glow.
“Oh, you are fine! How amazing!” A fluffy little creature jumped out from behind a tree, with pointy ears and big eyes, it was a little fox spirit. “I am Pipihux, I just saw you fall from the sky, what an impressive spell!”
Before Liuyuyan could respond, an old man with a long white beard floated down from the clouds, dressed in a green Daoist robe, exuding an aura of immortality. “Young friend, you have descended from the heavens, and there is a strange spiritual energy fluctuation about you. Would you like to follow me to the Instant Noodle Sect for a chat?”
“Instant Noodle Sect?” Liuyuyan asked in confusion.
The old man stroked his beard and smiled, “That is the name of my sect, named after our ancestor who loved to eat instant noodles. I am Qingjiao Zhenren, and I see you have extraordinary potential, a rare talent for cultivation! However…”
Qingjiao Zhenren changed his tone, “To join our sect, you must pass the entrance test. Are you willing to accept the spell challenge?”
Liuyuyan hesitated and asked, “What is a spell?”
The old man stroked his beard and smiled, “A spell is the foundation of cultivation, capable of summoning the spiritual energy of heaven and earth, manipulating all things in the world.”
As he spoke, he wrote a line of code in the sky:
#include<iostream>
using namespace std;
int main() {
cout << "Hello world!" << endl;
}
Then, a huge fireball flew out from the sky, exploding with a bang, transforming into a ball of flames that shot into the clouds.
Liuyuyan was stunned, “This… is this a spell?”
“Yes, this is our sect’s supreme ‘Fireball Technique’!” Qingjiao Zhenren said proudly.
Liuyuyan thought to herself, “Isn’t this just the program I wrote when I first learned C++ before crossing over? Could it be that in this world, programming in C++ can cast spells?” So, she decided to give it a try and replied, “Thank you, I am ready!”
“Very good!” Qingjiao Zhenren nodded in satisfaction, and with a wave of his hand, the surrounding scenery suddenly changed. They arrived in a mysterious bamboo forest, where the bamboo leaves sparkled with glowing dots.
“This is the Illusion Bamboo Array, your first test is to find your own ‘spiritual root’.” Qingjiao Zhenren said, tapping Liuyuyan’s abdomen, and she felt a warm current flowing within her.
“Now, try to feel the spiritual root in your dantian. Remember, the path of cultivation is fraught with dangers, and only those with wisdom and courage can succeed.”
Liuyuyan closed her eyes and looked inward, surprised to find a small glowing space in her dantian, which seemed capable of storing various things.
“Awesome!” Pipihux exclaimed, “Quick, check your spiritual root attributes!”
Technical Tips
- The dantian is like a variable in C++, a place to store information.
- Spiritual roots have different attributes, just like variables have different types.
- Fire spiritual root (int) stores integers, such as age and quantity.
- Water spiritual root (double) stores decimals, such as height and weight.
- True spiritual root (bool) stores true or false values, such as switch states.
- Virtual spiritual root (string) stores text, such as names and spells.
#include<iostream>
#include<string>
using namespace std;
int main() {
// Open different attributes of spiritual roots in the dantian
int fire_power = 10; // Fire spiritual root, stores integers
double water_magic = 3.14; // Water spiritual root, stores decimals
bool truth_eyes = true; // True spiritual root, stores true or false
string spell_name = "Fireball Technique"; // Virtual spiritual root, stores text
// Check the spiritual power values in each root
cout << "Fire spiritual root strength: " << fire_power << endl;
cout << "Water spiritual root strength: " << water_magic << endl;
cout << "True eye state: " << truth_eyes << endl;
cout << "Spell name: " << spell_name << endl;
return 0;
}
Qingjiao Zhenren explained, “You see, this is like opening four different attributes of spiritual roots in your dantian. <span>int fire_power = 10;</span> is like planting a fire spiritual root in the dantian, specifically for storing integers. And <span>double water_magic = 3.14;</span> is the water spiritual root, which can store decimals.”
Pipihux interjected, “Then what about this <span>bool truth_eyes = true;</span>?”
“This is the true spiritual root, which can only store true (true) or false (false) states, just like your eyes can either be open or closed,” Qingjiao Zhenren patiently explained.
Liuyuyan tried to run a spell, and before her appeared:
Fire spiritual root strength: 10
Water spiritual root strength: 3.14
True eye state: 1
Spell name: Fireball Technique
“Wow! So amazing!” Liuyuyan exclaimed excitedly.
“It seems you have initially grasped the secrets of the spiritual roots,” Qingjiao Zhenren smiled while stroking his beard. “But to truly master these powers, you must continue to practice.”
After explaining the concept of spiritual roots, Liuyuyan eagerly wanted to try it out.
“Let me give it a shot!” Liuyuyan said excitedly, starting to write simple C++ code in her mind.
#include<iostream>
using namespace std;
int main() {
int fire_power = 5; // Fire spiritual root power
cout << "Fireball Technique activated! Strength: " << fire_power << endl;
return 0;
}
As the code ran, the fire spiritual root in her dantian shone brightly, and a ball of intense flame formed in her palm, which then transformed into a small fireball flying towards a nearby bamboo, leaving a small scorch mark with a soft bang.

“Wow! It really worked!” Liuyuyan jumped up in excitement, this was the skill she had longed for before crossing over!
Pipihux watched in awe, “Master is amazing! You mastered the use of spiritual roots so quickly!”
Qingjiao Zhenren nodded with a smile, “Not bad, it seems you have begun to understand the spiritual roots. But remember, the path of cultivation is long, and this is just the beginning.”
Just then, a sinister laugh echoed from deep within the bamboo forest: “Hmph, another ignorant little one has come…”
“Who is it?” Liuyuyan looked around warily.
“Don’t be nervous,” Qingjiao Zhenren comforted, “This is just part of the test. Remember, a true cultivator must not only learn to control spiritual power but also learn to face fear and the unknown.”
Practice Time
-
(Difficulty: ★) If I want to store my age (13 years) and height (1.62 meters) in the dantian, what spiritual roots should I use? Please write the corresponding C++ code.
-
(Difficulty: ★★) What will the following code output?
#include<iostream>
using namespace std;
int main() {
int a = 5;
int b = a + 3;
cout << "The value of b is: " << b << endl;
return 0;
}
- (Difficulty: ★★) Liuyuyan wants to record whether she learned a new spell today and the name of the spell she learned. What two types of spiritual roots should she use? Please explain why.
Answers and Comments
- Answer:
int age = 13; // Use fire spiritual root to store age (integer)
double height = 1.62; // Use water spiritual root to store height (decimal)
Comment: Age is an integer, so it should use int type (fire spiritual root); height is a decimal, so it should use double type (water spiritual root).
- Answer:
The value of b is: 8
Comment: First, a is assigned the value of 5, then b is assigned the value of a + 3, which is 5 + 3 = 8, so the output result is 8.
- Answer: She should use bool type (true spiritual root) and string type (virtual spiritual root).
bool learned_new_spell = true; // Record whether a new spell was learned
string spell_name = "Invisibility Technique"; // Record the name of the spell
Comment: Whether a new spell was learned is a true or false question, so it should use bool type; the spell name is text information, so it should use string type.
Today’s Mantra
The dantian is like a variable, spiritual roots are of different types, fire, water, true, and virtual are all different.
After repeated practice, Liuyuyan gradually mastered the newly learned spell techniques. Each successful execution of code made her feel the energy in her spiritual roots becoming more abundant. She realized that as long as she followed the mantra taught by her master Qingjiao Zhenren step by step, even the most complex formations (code logic) could be easily cracked.
Pipihux excitedly exclaimed, “Master is amazing! It seems we won’t be afraid next time when the cold duck presents a difficult problem!”
Liuyuyan nodded, secretly summarizing in her heart: “Writing code is like injecting true energy, every step must be precise to achieve the desired effect.”
As her practice deepened, Liuyuyan gradually mastered the basic use of spiritual roots. But her journey of cultivation had just begun…
≡