portal:http://noi.openjudge.cn/ch0102/
A set of water problems, but they are still the problem
01-03 is the basic data type storage space size
01
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {int A; Short b;cout<<sizeof(a) <<'<<sizeof(b) ; return 0 ;}
View Code
02
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {float A; Double b;cout<<sizeof(a) <<'<<sizeof(b) ; return 0 ;}
View Code
03
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {char A; BOOL b;cout<<sizeof(a) <<'<<sizeof(b) ; return 0 ;}
View Code
Well, in fact, sizeof () is a relatively unpopular in OI statement, but in the measurement of the space consumption of the topic is useful
The next time you encounter an SB problem, use it to measure the space.
That's right
Basic data type storage space size
BOOL 1 (bytes)
Char 2
Short 2
int 4
Long 4
Float 4
Double 8
Long Double 16
Long Long 8
So what can we learn from it?
What I understand is:
1. Wretched to use bool and char (+hash? ) store 255 or less of the data
2. Up to 300W for 256MiB space array
Up to 80W for 65536KB spatial arrays (various basic data structures)
3. Do not set a map,map in the vector and set a pair and a queue, do not do the big constant Master
04 05: ... you're teasing me. answer questions in a variety of ways
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {cout<<'D'<<'<<' C ' ; return 0 ;}
View Code
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {cout<<'F'<<'<<' E ' ; return 0 ;}
View Code
06 07 08 09: Forced type Conversion
Format has (type specifier) (expression), type specifier ((expression)), etc.
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {float A; int b;cin>>a;b=a;cout<<b; return 0 ;}
View Code
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {char A; int b;cin>>a;b=a;cout<<b; return 0 ;}
View Code
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {int A; Char b;cin>>a;b=a;cout<<b; return 0 ;}
View Code
#include <iostream>#include<cstring>#include<cstdio>using namespace std; int Main () {int A; BOOL b;cin>>a;b=a;a=b;cout<<A; return 0 ;}
View Code
10: Hehe "Hello, the size of world!" This question is also can
#include <iostream>#include<cstring>#include<cstdio>int main () { printf ("%d",sizeof("Hello, world! " )); return 0 ;}
View Code
Overall: Although water, but very good, these questions are not focus on practice and results, but to guide students to "explore" C + + language usage and standards
I have to say, CCF did a good deed.
1.2 Variable definition, assignment and conversion of programming basics