# include & lt; Stdio. H>
Int main (void)
{
Long long signed this_is_a_var_a this_is_a_var_b;
This_is_a_var_a=5;
This_is_a_var_b=this_is_a_var_a + 7;
Printf (" % LLD \ n ", this_is_a_var_b);
}
I told zhao old wet, such a small program, it is not necessary to get the variable name for such a long, don't have to declare a signed long long, zhao old wet, said that not line, one thousand after I get a big number? You see:
long long signed this_is_a_var_a=1234567890;
This a, building the net friend, you said it also get yao, om?
(note: be free and at leisure, with zhao old wet gag, don't know the situation of not such online!)
CodePudding user response:
CSDN is getting more popular touch, himself a,I said zhao old wet, you will demonstrate a 5 plus seven equals 12, why should get a long long signed, make an int also saves energy, you can't have too tired, old wet which Ken zhao, then change the program, said, you see,
This_is_a_var_a=12394572389446723543;
It's not useful? Zhao old wet creature suddenly let everybody admire uh-uh, building all say me is wrong, said zhao old wet you well done, well done, it should be so! No statement into a long long number can easily be truncation errors, saw everyone's speech, the older the wet suddenly look up, the hotel is full of happy air,
CodePudding user response:
Zhao four teachers live whereCodePudding user response:
CodePudding user response:
By the gain in your wit!It, bad habits change
CodePudding user response:
Even if you write a# include & lt; iostream>
#include
using namespace std;
The inline int the compare (string str1, string str2) {//return equal 0, is greater than the return 1, less than the return 1
If (str1. The size () & gt; Str2. The size ()) return 1;//the length of the long integer greater than the length of the integer
Else if (str1. The size () & lt; Str2. The size ()) return 1;
The else pare said return str1.com (str2);//if equal length, head to tail according to the comparison of
}
String SUB_INT (string str1, string str2);
String ADD_INT (string str1, string str2) {//high precision addition
Int sign=1;//sign for the sign bit
string str;
If (str1 [0]=='-') {
If (str2 [0]=='-') {
Sign=1;
STR=ADD_INT (str1. Erase (0, 1), str2. Erase (0, 1));
} else {
STR=SUB_INT (str2, str1. Erase (0, 1));
}
} else {
If (str2 [0]=='-') {
STR=SUB_INT (str1, str2. Erase (0, 1));
} else {//alignment, the two integers up short integer adding 0
String: : size_type L1, L2,
int i;
L1=str1. The size ();
L2=str2. The size ();
If (L1 & lt; L2) {
For (I=1; i<=L2 - L1. I++) str1="0" + str1;
} else {
For (I=1; i<=L1, L2, I++) str2="0" + str2;
}
Int int1=0, int2=0;//record int2 carry
For (I=str1. The size () - 1; i>=0; I -) {
Int1=(int (str1 [I]) - '0' + int (str2 [I]) - '0' + int2) % 10;
Int2=(int (str1 [I]) - '0' + int (str2 [I]) - '0' + int2)/10;
STR=char (int1 + '0') + STR.
}
If (int2! STR==0) char (int2 + '0') + STR;
}
}
//operation post-processing the sign bit
If ((sign==1) & amp; & (STR [0]! STR='0'))="-" + STR;
return str;
}
String SUB_INT (string str1, string str2) {//high precision subtraction
Int sign=1;//sign for the sign bit
string str;
int i,j;
If (str2 [0]=='-') {
STR=ADD_INT (str1, str2. Erase (0, 1));
} else {
Int res=compare (str1, str2);
If (res==0) return "0".
If (res<0 {
Sign=1;
String temp=str1;
Str1=str2;
Str2=temp;
}
String: : size_type tempint;
Tempint=str1. The size () - str2. The size ();
For (I=str2. The size () - 1; i>=0; I -) {
If (str1 + tempint [I]J=1;
While (1) {//zhao4zhong1 add
If (str1 [I + tempint - j]=='0') {
Str1 [I + tempint - j]='9';
j++;
} else {
Str1 [I + tempint - j]=char (int (str1 [I + tempint - j]) - 1);
break;
}
}
STR=char (str1 + tempint [I] - str2 [I] + ':') + STR.
} else {
STR=char (str1 + tempint [I] - str2 [I] + '0') + STR.
}
}
For (I=tempint - 1; i>=0; I -) STR=str1 [I] + STR;
}
//remove the excess of leading 0
STR. Erase (0, STR. Find_first_not_of (' 0 '));
If (STR) empty ()) STR="0";
If ((sign==1) & amp; & (STR [0]! STR='0'))="-" + STR;
return str;
}
String MUL_INT (string str1, string str2) {//high precision multiplication
Int sign=1;//sign for the sign bit
string str;
If (str1 [0]=='-') {
Sign *=1;
Str1=str1. Erase (0, 1);
}
If (str2 [0]=='-') {
Sign *=1;
Str2=str2. Erase (0, 1);
}
int i,j;
String: : size_type L1, L2,
L1=str1. The size ();
L2=str2. The size ();
For (I=L2-1; i>=0; I -) {//analog multiplication by hand upright
String tempstr;
Int int1=0, int2=0, int3=int (str2 [I]) - '0'.
If (int3!=0) {
For (j=1; j<=(int) (L2-1 - I); J++) tempstr="0" + tempstr;
For (j=L1-1; J>=0; J -) {
Int1=(int3 * (int (str1 [j]) - '0') + int2) % 10;
Int2=(int3 * (int (str1 [j]) - '0') + int2)/10;
Tempstr=char (int1 + '0') + tempstr;
}
If (int2! Tempstr==0) char (int2 + '0') + tempstr;
}
STR=ADD_INT (STR, tempstr);
}
//remove the results of the leading 0
STR. Erase (0, STR. Find_first_not_of (' 0 '));
If (STR) empty ()) STR="0";
If ((sign==1) & amp; & (STR [0]! STR='0'))="-" + STR;
return str;
}
String str2 string DIVIDE_INT (string str1, int flag) {//high precision division, the flag==1, return to business; Flag==0, return to the remainder
String quotient, residue;//define the quotient and remainder
Int sign1=1, sign2=1;
If (str2=="0") {//whether divisor of 0
Quotient="ERROR!" ;
Residue="ERROR!" ;
If (flag==1) return quotient;
The else return residue;
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull