Hello guys, welcome to my blog. I am DumDum and today we are going to do our first beginner tutorial on C++.
Today we will start with the most beginner stuff, printing a line in C++.
I will just copy and paste my template, wait a second...
//This is a comment, in a comment you can write whatever shid you want to write, the compiler won't complain
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef long long int lli;
#define prnt(a) cout << a << "\n"
#define prnt2(a, b) cout << a << " " << b << "\n";
#define forp1(a) for (lli i = 0; i < a; i++)
#define forp2(a, b) for (lli i = a; i < b; i++)
#define forf(a, b, c) for (lli i = a; i < b; i += c)
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
//YOu see, commputers are dumb, they don't understand human language. So we can't print
//letter directly. But don't lose hope, their is a trick to make computers write our language
//Let's start by printing "I am too dumb to program :("
string s = "I am too dumb to program :(";
//The compiler thakes the string, and converts it into an array of numbers
//It's stored somewhere in your desktop, you will need an electron microscope to see them
//We are going to use this numbers to print them in human readable language
//Since computers don't understand characters, we will need to convert them into numbers
//binary numbers more specifically. As you see, computer understands only 0 and 1.
//Fortunately, the compiler here can help us convert numbers into their binary form
for (int i = 0; s[i] != '\0'; i++){
int n = 1;
n <<= 1;
//Here goes a small efficiency boost to improve the average complexity of the programm
//Since humans use mostly letters, this is like to speed up you process by some number
//I am bad at maths :(
if (s[i] >= 'a' && s[i] <= 'z') {
n |= 1;
}
else if (s[i] > 'Z' || s[i] < 'A'){
n >>= 1;
}
n <<= 5;
//I am too dumdum to handle this
while (n != s[i]){
int temp = n;
lli x = 1;
while (temp & 1){
temp >>= 1;
x <<= 1;
x |= 1;
}
n ^= x;
}
cout << (char) n;
}
//Yes, programming is hard, don't complain
}
And here we go, we have learnt to print a string!
The tutorial is too big to post in a single blog. Um, I will ask my Indian friend to upload a video on this