, , . , . , . . , , .
, . , .
, , . . . , .
void print(int a[100],int n) //
{
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<"\n";
}
( ), .
++ - , - \0 (-). - . 1 , .
, string.h.
char char*. , . . /0.
//
int find(char *s,char c)
{
for (int I=0;I<strlen(s);I++)
if(s[I]==c) return I;
return 1
}
, . , int a[4][5] int*, 5 :
. , .
.
const int N=4;//
void transp(int a[][N],int n)//
{
int r;
for(int I=0;I<n;I++)
for(int j=0;j<n;j++)
if(I<j)
{
r[a[I][j];
a[I][j]=a[j][I];
a[j][I]=r;
}
}
C++ , - \0 (-). - . 1 , .
A | \0 | A | |
A (2 ) | A (1 ) |
|
|
. 4.
. , .
char s1[10]="string1";//
char s2[]="string2";//
char s3[10];
cin>>s3;//
//
char *s4=new char[strlen(s3)+1];
strcpy(s4,s3);// s3 s4
, string.h.
unsigned strlen(const char* s); | s. | |
int strcmp(const char* s1, const char* s2); | s1 s2. | s1<s2, , s1==s2, 0, s2>s1 . |
int strcnmp(const char* s1, const char* s2); | n s1 s2. | s1<s2, , s1==s2, 0, s2>s1 . |
char* strcpy(char* s1, const char* s2); | s1 s2. | |
char* strncpy(char* s1, const char* s2, int n); | n s1 s2. | . |
char* strcat(char* s1, const char* s2); | s2 s1 | |
char* strncat(char* s1, const char* s2); | n s2 s1 | |
char* strdup(const char* s); | s |
char char*. , . . \0.
1. .
2. , , .
3. .
4. , , .
5. , .
. | . | . | |
. | . | . | |
. | . | . | |
. | . | . | |
. | . | ( ). | |
. | . | , . | |
. | , . | , . | |
. | , . | . | |
, . | . | . | |
min(a[1],a[3],a[2n-1]). | . | . | |
, 0. | . | . | |
, , . | . | ( ). | |
. | . | , . | |
. | . | , . | |
. | . | . | |
. | . | . | |
. | , . | . | |
. | , . | . | |
. | . | ( ). | |
. | . | , . | |
, . | . | , . | |
min(a[1],a[3],a[2n-1]). | . | . | |
, 0. | . | . | |
, , . | . | . | |
. , . | . | . |
|
|
1. , . .
2. , .
|
|
3. . , .
4. / :
char* gets(char*s)
int puts(char *s)
5. <string.h>
6. , 3.
7. main() / , /.
1. ( ).
2. , , / ( ).
3. main().
4. .
5
1. :
1. ,
. , . . , , .
new, C++:
= new _[];
.
new , . , , .
int* x=new int(5);
delete, C++:
delete ;
, new.
delete x;
new :
new _
, . new , . .
// 100*sizeof(int)
int* a = new int[100];
, n .
/* */
int** form_matr(int n,int m)
{
int **matr=new int*[n];//
for(int i=0;i<n;i++)
// 100*sizeof(int)
matr[i]=new int [m];
return matr;//
}
*matr[0] | *matr[1] | *matr[2] | .. | *matr[n] |
.
, . . delete.
/* , , */
delete[] a;
, . . , , , .
|
|
int find(int **matr,int m,int I)
{
for(int i=0;i<m;i++)
if(matr[I][i]<0) return 1;
return 0;
}
, . .
int **del(int **matr,int &n,int m)
{//
int k=0,t=0;
for(int i=0;i<n;i++)
if(i % 2!=0)k++;//
//
int **matr2=form_matr(k,m);
for(i=0;i<n;i++)
if(i % 2!=0)
{
// ,
for(int j=0;j<m;j++)
matr2[t][j]=matr[i][j];
t++;
}
n=t;//
//
return matr2;
}
1. , .
2. .
3. , .
4. .
() | ||
N , K | ||
, 1 2 | ||
, 1 2 | ||
, N | ||
0 | , | |
, | ||
, | ||
N , K | ||
, N | ||
, N | ||
, | ||
, |
1. new, delete.
2. , , (, ) . main() :
int main()
{
int n;
cout<<"N?";cin>>n;
person*mas=form_mas(n);
init_mas(mas,n);
print_mas(mas,n);
return 1;
}
3. :
.
do
{
cout<<1. \n;
cout<<2. \n;
cout<<3. \n;
cout<<4. \n;
|
|
cout<<5. \n;
cin>>k;
switch (k)
{
case 1: mas=form_mas(SIZE);input_mas(mas,SIZE); break;//
case 2: print_mas(mas,SIZE); break;//
case 3: del_mas(mas,SIZE);break;//
case 4: add_mas(mas,SIZE);break;//
}
while (k!=5);//
4. (, ) , . . , (, ) (, ). .
1. ( ).
2. .
3. main().
4.
6