#include <iostream>#include<string>using namespacestd;int*F1 (int*i) { ++(*i); returni;}int*F2 (int*i) { returni;}voidF3 (int*i,int*j) {cout<< *i <<" "<< *j <<Endl;}intMainvoid){ //04.sizeof again intc[Ten];int*u =C; cout<<sizeof(u) <<" "<<sizeof(*u) <<" "<<sizeof(c) <<" "<<sizeof(*c) <<Endl; //The result is:4 4 4//03. Order of Evaluation intK =0, j =0; F3 (F2 (&J), F1 (&j));//output in either order: 1 1 while(K < +) cout<<++k<<" "<<k<<endl;//output in either order: 1 1//01. Read one line of characters, convert the first letter of each word to uppercase, use an iterator to implement strings; inti =0; Getline (CIN, s); for(Auto B = s.begin (); B!=s.end (); b++) { if(Isspace (*b)) I=0; Else if(i = =0) { *b = ToUpper (*b); I=1; } Elsei =1; } cout<<"\ n"<<s<<Endl; //02. Initialize each element in the array to its own ordinal, size_t = unsinged int Const intC1 =3, C2 =4; intA[C1][C2]; for(i =0; i<c1; i++ ) { for(intj =0; j<c2; J + +) {A[i][j]= I*c2 +J; cout<<a[i][j]<<' '; } cout<<Endl; } getchar ();}
#include <iostream>
#include <string>
using namespace Std;
int *f1 (int *i)
{
+ + (*i);
return i;
}
int *f2 (int *i)
{
return i;
}
void F3 (int *i, int *j)
{
cout << *i << << *j <<endl;
}
int main (void)
{
04.sizeof again
int c[10]; int *u = c;
Cout<<sizeof (U) << "<<sizeof (*u) <<" "<<sizeof (c) <<" "<<sizeof (*C) < <endl;
The result is:4 4 40 4
03. Order of Evaluation
int k =0, j = 0;
F3 (F2 (&j), F1 (&j)); Output in either order: 1 1
while (K < 21)
cout <<++k<< "" <<k<<endl; Output in either order: 1 1
01. Read one line of characters, convert the first letter of each word to uppercase, use an iterator to implement
string S;
int i = 0;
Getline (CIN, s);
for (Auto B = s.begin (); B!=s.end (); b++)
{
if (Isspace (*b))
i = 0;
else if (i = = 0)
{
*b = ToUpper (*b);
i = 1;
}
else i = 1;
}
cout<< "\ n" <<s<<endl;
02. Initialize each element in the array to its own ordinal, size_t = unsinged int
const INT C1 = 3, c2 = 4;
int A[C1][C2];
for (i = 0; i<c1; i++)
{
for (int j = 0; j<c2; j + +)
{
A[I][J] = i*c2 + j;
cout<<a[i][j]<< ";
}
cout<<endl;
}
GetChar ();
}
2015.09.08 C + + notes