The answer to the previous blog post:
1://DataTypeDemo.cpp: Defines the entry point of the console application.
2://
3:
4:"stdafx.h"
5: #include <iostream>
6:/*
7:1\ input score, tell us level
8:
9: Self-set a B C zone
10:
One :2\ input A class of results, can also not input, directly with the array to represent 20 people
12:
90 +% of output
14:
: percentage of output 80--90
:* /
17:
:int _tmain (int argc, _tchar* argv[])
: {
:using std::cout;
:using std::cin;
:using Std::endl;
://First question
:char rank;
:double gread = 0.0;
A :"Please enter your score:" << Endl;
: scanf_s ("%d", &gread);
:if (Gread >= 90)
: {
:' A ';
: }
:Else if (Gread >= 85)
: {
:' B ';
: }
:Else if (Gread >= 60)
PNs: {
:' C ';
: }
+ :Else{
A :' d ';
: }
"Your rating is:" << rank << Endl;
44:
///second question I'll write five here .
:int stuarray[] = {22,44,88,98,89};
:int acout=0, bcout=0, ccout=0,dcout=0;
:intsizeofsizeof(int);
$:for (int index = 0; index < stulength;index++)
: {
Wuyi:if (Stuarray[index] >= 90)
£ º acout++;
:Else if (Stuarray[index] >= 80)
Wu : bcout++;
:Else if (Stuarray[index] >= 60)
: ccout++;
:Else
: dcout++;
: }
:"90 + percent is:%" << acout *100/stulength<< Endl;
"Percentage of 80--90:%" << bcout*100/stulength << Endl;
: system ("pause");
+ :return 0;
: }
65:
About the use of scopes and variables in C + +, here I don't write, too simple.
C + + Expressions:
1. Number of bytes: sizeof ()
2. Subscript operator []
3. Assignment operator =
4. Arithmetic operator +-*/
5, relational operator ++–, etc.
C + + pointers:
Let's go through an array of explanations:
1://pointDemo.cpp: Defines the entry point of the console application.
2://
3:
4:"stdafx.h"
5: #include <iostream>
6:
7:int _tmain (int argc, _tchar* argv[])
8: {
9:using std::cout;
:using std::cin;
One :using Std::endl;
12:
:int narray[] = {1,5,3,4,5,6,7,8,};
:sizeofsizeof(int) << Endl; //sizeof to find size
:int *parray = NArray; //narray The first pointer to an array
: cout << parray << Endl; //So the address is printed here
: cout << *parray <<"* * * *"<<pArray[0]<< Endl; //This is =narray[0]
:"*-********" << Endl;
: cout << nArray + 1 << endl;
: cout << * (NArray + 1) << Endl; //Here is Narray address +1 i.e. narray[1]
: cout << *parray + 1 << endl; //The output here is narray[0]+1=2
: system ("pause");
At :return 0;
: }
25:
Demo
1. Define an array for all data types, and then print out their addresses
2, do not use subscript, change the value in the array
3. Define all the underlying data types as pointers and manipulate the values inside them with pointers
4, int * Change to short * and print the same result (the number entered cannot exceed the size of short)
C + + escape character, pointer