TAILIEUCHUNG - ASP.NET 2.0 - PART 3

Tham khảo tài liệu ' - part 3', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 196 Appendix B Common Codes Routines For Programming We can convert a negative number mod n to positive number by adding a multiple of n to it. Multiplication - xy mod n. x mod n y mod n mod n. What is xy mod n. Exponentiation is just repeated multiplication x mod n y mod n. So if the x and y are very big equal to 32 bit. Then we can also compute it without overflow. Big mod include long square long s return s s long bigmod long b long p long m if p 0 return 1 else if p 2 0 return square bigmod b p 2 m m square x x x else return b m bigmod b p-1 m m int main long b p m sum while Scanf ld ld ld b p m 3 sum bigmod b p m printf ld n sum return 0 Number Conversions - Integer 1 Binary Convert an integer number into binary number int inttobin unsigned int a int bin int one 0 unsigned int c 1 int i for i 31 i 0 i-- one one a c bin i a c 1 0 c 1 return one Convert a binary number into binary number unsigned int creatnum int num int i unsigned int a 0 for i 0 i 32 i a a num i if i 31 a 1 return a 197 Appendix B Common Codes Routines F or Programming Integer A hex A Integer char hex 100 int num 4095 sprintf hex X num convert the num in upper case hex decimal in hex sprintf hex x num convert the num in lower case hex decimal in hex sscanf hex x num convert the hex number hex in integer num Integer to any base Following code help you to convert any integer number on any base from 2 to 36. include include define MAXDGT 200 maximum number of digit A general swap function that swap two object. Input Two object. Return None template class T void swap T x T y T tmp x x y y tmp A general string reverse function that reverse the passed string and store the string int to the parameter. Input A string Return None void revstr char str int i 0 l strlen str while i l swap str i str --l A general base conversion function Input A number n and a base b Return A character array which contain the number n in base b char itob long int n int b 10 char num MAXDGT int j .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.