30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

printf("The absolute value of %7ld is %6ld\n",<br />

i, labs(i));<br />

}<br />

Output:<br />

The absolute value of123456 is 123456<br />

The absolute value of -246834 is 246834<br />

The absolute value of 0 is 0<br />

getenv (Continued)<br />

Standard C Libraries with Math Functions<br />

2004 Microchip Technology Inc. DS51456B-page 283<br />

ldiv<br />

Bao gồm:<br />

Nguyên mẫu: int mbtowc (wchar_t * PwC, const char * s, size_t n);<br />

Đối số: điểm PwC cho nhiều nhân vật<br />

s điểm cho nhân vật nhiều byte<br />

số n byte để kiểm tra<br />

Quay trở lại giá trị: Trả về số không nếu spoints cho một nhân vật null; nếu<br />

không, trả về 1<br />

Ghi chú: Các ký tự rộng kết quả sẽ được lưu trữ tại PwC. MPLAB C30 không<br />

không hỗ trợ các ký tự nhiều byte có chiều dài lớn hơn 1 byte.<br />

dsPIC<br />

®<br />

Thư viện Công cụ Ngôn ngữ<br />

Description: Calculates the quotient and remainder of two long integers.<br />

Include: <br />

DS51456B trang 286<br />

qsort<br />

2004 Microchip Technology Inc<br />

Prototype: ldiv_t ldiv(long numer, long denom);<br />

Arguments: numer numerator<br />

denomdenominator<br />

Return Value: Returns the quotientand the remainder.<br />

Remarks: The returned quotient will have the same sign as the numerator<br />

divided<br />

by the denominator. The sign for the remainder will be such that the<br />

quotient times the denominator plus the remainder will equal the<br />

numerator (quot * denom + rem = numer). If the denominator is zero,<br />

the behavior is undefined.<br />

Example: #include /* for ldiv, ldiv_t */<br />

#include /* for printf */<br />

int main(void)<br />

{<br />

long x,y;<br />

ldiv_t z;<br />

x = 7;<br />

y = 3;<br />

printf("For ldiv(%ld, %ld)\n", x, y);<br />

z = ldiv(x, y);<br />

printf("The quotient is %ld and the "<br />

"remainder is %ld\n\n", z.quot, z.rem);<br />

x = 7;<br />

y = -3;<br />

printf("For ldiv(%ld, %ld)\n", x, y);<br />

z = ldiv(x, y);<br />

Mô tả: Thực hiện sắp xếp nhanh chóng.<br />

Bao gồm:<br />

Prototype: void qsort (void * cơ sở, nelem size_t, size_t size,<br />

int (* CMP) (const void * e1, const void * e2));<br />

Con trỏ cơ sở để bắt đầu của mảng: đối số<br />

số nelem của các yếu tố<br />

kích thước kích thước của các yếu tố<br />

CMP con trỏ đến chức năng so sánh<br />

e1 con trỏ đến chìa khóa cho các con trỏ tìm kiếm e2 cho các phần tử được so<br />

sánh với phím<br />

Bình luận: qsortoverwrites mảng với mảng được sắp xếp. Việc so sánh<br />

chức năng được cung cấp bởi người sử dụng. Inthe ví dụ sau đây, trong danh<br />

sách là<br />

sắp xếp theo chức năng so sánh. Đây compuses<br />

thứ tự tăng dần.<br />

Ví dụ: # include / * Cho qsort * /<br />

# include / * Cho printf * /<br />

# xác định NUM 7<br />

int comp (const void * e1, const void * e2);<br />

int main (void)<br />

{<br />

int danh sách [NUM] = {35, 47, 63, 25, 93, 16, 52};<br />

int x;<br />

printf ("Danh sách Unsorted:");<br />

for (x = 0; x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!