.


:




:

































 

 

 

 





qsort , . :

void qsort(void *base, size_t n, size_t size, int (*cmp) (const void *e1, const void *e2));

stdlib.h. :

base ,

n ,

size ,

cmp , :

, e1 e2;

0, e1 e2;

, e1 e2.

 

/* */

int comp_int(const int* e1, const int* e2)

{

return (*e1-*e2);

}

 

bsearch . :

void* bsearch(const void *key, const void *base,

size_t n, size_t size, int (*cmp)(const void *ck, const void *ce);

stdlib.h. key , . qsort. bsearch , NULL.

 

/* */

int comp_int(const int* e1, const int* e2)

{

return (*e1-*e2);

}

 

.

( )

.

#include <stdio.h>

#include <math.h>

void Revers(char *a,int n)

{
int k;


//


for (int i=0;i<n/2;i++)

{
k=a[i];

a[i]=a[n-i-1];

a[n-i-1]=k;

}

}

 

void Psystem(double re, int si,char s[],int *n)

{
int r,i,z=0;

double dre;

unsigned char c_c[]="0123456789abcdef";

double y=modf(re,&dre);

int x=dre;

i=0;
while (x>=si)

{ r=x % si;

x=x / si;

s[i]=c_c[r];

i++; }

s[i++]=c_c[x];

Revers(s,i);
if (y!=0)

{ s[i++]='.';z=0;

do
{ re=modf(re,&dre);

re = re*si;

int j=re;

s[i++]=c_c[j];

z=z+1;

}

while (re!=0 && z!=10);

} *n=i;}

 

void main(void)

{

double re,dre;

int si,n;

char s[100];

printf(" (2..16):");

scanf("%d",&si);

printf(" : ");

scanf("%lf",&re);

Psystem(re,si,s,&n);

PrintArray (s,n);


}

 

14 ++ .

. char.

ASCII, : "...". char[].

.

, '\0' ( ).

:

char *str;

char str[10];

char str[]={T,g,\0};

0 , .

, str :

str == &str[0], *str == 'T', *(str+1) == str[1] == 'h'

 

 

char heart[ ] = " C++";

char *head = " Pascal";

, heart , head - .

.

 

, . , .

 

 

char* gets(char *str);

. . , NULL.





:


: 2016-07-29; !; : 569 |


:

:

: , .
==> ...

1967 - | 1582 -


© 2015-2024 lektsii.org - -

: 0.013 .