Post on 04-Jan-2016
description
C
[]
[]
CCC
[]int a[5];
123arrry[10]arrry 100
[]={};{} int array[5]={ 1,2,3,4,5};5arrayarray [0]=1array[1]=2array[2]=3array[3]=4array[4]=5
int array[5]={1,2,3};array [0]=1array[1]=2array[2]=30array[3]=0array[4]=0
int array[]={ 1,2,3,4,5};5
[]int array[5]={ 1,2,3,4,5};a=array[3];array[3]=6;
Cn0n
R[1..i-1] R[i..n] i R[1..i] R[i+1..n]
tag=i; //tag // // //ilengthfor(j=i;ja[j]) tag=j; ////a[tag] //a[i]buffer=a[tag];a[tag]=a[i];a[i]=buffer;
a [0]a [1]sorttagiimainarraymainarraysorta
10()
R[1..n] i R[1..n-i+1]
R[n-i+2..n]
n-i+1R[1..n-i]
R[n-i+1..n]
n-i+1
X-YXY
[1][2];12 int array[2][3]; array
0nm0n-10m-1
int array[2][3]={1,2,3,4,5,6};int array[2][3]={{1,2,3},{4,5,6}};
int array[2][3]={1,2,3};array[0][0]array[0][1]array[0][2]1230int array[2][3]={{0,2},{4}};array[0][0]=0array[0][1]=2array[0][2]=0array[1][0]=4array[1][1]=0array[1][2]=0
int array[2][3]={1,2,3,4,5,6};int array[][3]={{2},{4,5,6}};
[] [][]int array[2][3]={ 1,2,3,4,5,6};a=array[1][0]; array[1][0]=6;array4a6
C++C++C++
41
&int var;&var var
C
C
*; int *p; //pfloat *q; //qchar f ,*r; //fr
*=;& &int a=5,*p=&a; appa
int a=5, *p; p=&a;0stdio.hNULL
*
void splitfloat(float x, int *intpart,float *fracpart){ //intpart fracpart *intpart = int(x);// x *fracpart = x - *intpart; //x}
Swap(int *p1,int *p2){ int temp; temp=*p1; *p1=*p2; *p2=temp;}
i()ishort array[8],*p;p=array; p=p+5;parraya[0]parray[5]
parrayp+i,p-i,p++,,p--,p+=i11ii short *p; p++;p22int *p; p++;p4
int array[10],*p,*q,n; p=array; q=p+2;n=q-p;parraya[0]parray[2]qpnn2
00 p==0p p!=0p0int *p;int b=*p;p*p
array[10]arrayarrayarray[0]array+iarray[i]array+i& array[i]array[2]*array+2
int a[10], *pa; pa=&a[0]; pa=a;*paa[0]*(pa+1)a[1]... *(pa+i)a[i].a[i], *(pa+i), *(a+i), pa[i] a++a
inta10
int array[3][4]arrayarray[0] array[1] array[2]array[0] array[1] array[2]array[0] array[1] array[2]
arrayarray[0] array[1] array[2]array+12array[1]array[0]+1array[0][1]array1array[0] array[1] array[2]
* *arrayarray[0] *array+1array[0]+1**arrayarray[0][0]* array[0]**array**array**
array[0]+1*(array +0)+1array[0][1]*(array[0]+1)array[0][1]*(*(array +0)+1)*(* array +1)array[0][1]*(array[i]+j)*(*(array +i)+j)array[i][j]*(array +i)array[i]
arrayarray+iarray [i]*(array+i)*(array+i)+jarray [i]+j*(array[i]+j)*(*(array+i)+j) array [i][j]array [i][j]
;
34naverage()search ()i
void average(float *p,int n);void search(float (*p)[4],int n);void main(){ float score[3][4]={{65,67,70,60}, {80,87,90,81},{90,99,100,98}}; average(*score,12);//12 search(score,2); //2}
*[]char *pc[5];5
int fun(int x,int y ,int z)int(*pfun)(int,int,int) int *pfun(int,int,int)pfun=fun;
*
*float *fun(int a , int b);
float *compute(float x,float y){ //floatresult // float *result=new float[4];//result*result=x+y;*(result+1)=x-y;*(result+2)=x*y;*(result+3)=x/y;return result; //result}
compute4resultmainpcomputeresultpp
C++
C++newdeletenewnew ;
NULL:int *p; p=new int(2); newint2pp
newnew []; NULL int *parr;parr=new int [5]; //5
deletedeletedelete p ; // delete delete [ ]parr; // delete []
Cvoid *malloc(unsigned int size);size()(void)()(NULL)
void free(void *p);ppmallocfree
C++C++
charchar c[10]; // 10 char c[10]= hello c++;char c[10]={hello c++}; char c2[]={ hello c++};
'\0''\0'
char week[][3]={Sun,Mon,The, wed,Thu,Fri}; 6week3
char *string, c[10]=hello c++; string=c;
stringcchar *string=hello c++; // char *string; // string=hello c++; //
char c[10]=hello c++; //// char c[10]; //c=hello c++;//
str2str1void str_cpy(char str1[] , char str2[]){char *p1=str1,*p2=str2; int i=0;while(p2[i]!='\0') { p1[i]=p2[i]; i++; //i } p1[i]=\0; //str1'\0'}
C++"stdio.h""string.h"
strlen( str ) (\0)
strcpy (str1,str2) str2str1\0
C++longcharintfloat
structstruct student{ long num; char *name;int majornum;float scores;};
1. ()struct student:struct student student1, student2;2. (), structstudent {} student1student2() struct {} student1student2
.zhangsan.numzhangsannumzhangsan.num=20061001; zhangsan.majornum=10;
= lisi=zhangsan;zhangsanlisi
struct student{ long num; char *name; int majornum; float scores;};
student group[10]; 10studentgroup
.a[1].num=20061002;student lisi; lisi=a[1];
struct student *ps; studentstruct&student zhangsan, *ps; ps=&zhangsan;
*student *ps=&zhangsan; lisi=*ps;(*ps).num=20061001;20061001zhangsannum.*(*ps) .num*p.num*(pnum)
->->.->->ps->num=20061001
n an an-1 ananan-1a1
#define LEN sizeof(struct student)struct student{ long num; float score; struct student *next;};
main(){ struct student *head; //creat head=creat() ; print1(head);}
sp
C++\0
C++newdelete