Programming Algorithm-division code (C)Division code (C)
Question: There are n items that have no difference. divide them into groups no more than m, and find the remainder of the division method D. M.
For example, m = 3 of n = 4, result = 4 (,
C and pointer (pointers on C) -- Chapter 12th: Using structures and pointers
Chapter 4 Structure and pointer
This chapter is the linked list. A single-chain table first, followed by a two-way linked list.
Summary:
A single-chain table is a data
Code for the number of times 1 appears in an integer from 1 to n (C)
Address: http://blog.csdn.net/caroline_wendy
Question: enter an integer n to calculate the number of times 1 appears in the decimal representation of the n integers from 1 to n.
# Import
// Switch function void swap (int x, int y) {printf ("x = % d, y = % d", x, y); int temp = 0; temp = x; x = y; y = temp; printf ("x = % d, y = % d", x, y );} // void swap2 (int * x, int * y) {// do not change the address. Change the
Description:
Input a positive integer array, splice all the numbers in the array into a number, and print the smallest of all the numbers that can be concatenated. For example, if the input array is {3, 32, 321}, the minimum number that can be
Parameter transfer:
PASS Parameters by value
ADT & black box
ADT: abstract data type, abstract data type
C can be used to design and implement abstract data types because it can restrict the scope of functions and data definitions. This
Data name indicates the first address
Pointer to array
#include
extern void iterate(int *p);void main(){int a[]={1,2,3,4,5};iterate(a);}void iterate(int *p){int i;for(i=0;i
Pointer to a one-dimensional array
Int (* p) [3]
# Import
Int main (int argc, const char * argv []) {# pragma mark ---------- array // The array is a container, same data type // construction type // int a [3] = {5, 2, 0}; // type // int [3]; // variable name //; // Initial Value // {5, 2, 0};
Pointer floating
Pointers are easily overlooked when we use pointers. The main manifestation is: the memory pointed to by pointers.
Release, the pointer is not set to NULL, resulting in an uncontrollable pointer.
# Include
# Include
Why do we need a system call? There are two main reasons.
(1) system calls provide a unified interface for user space to access hardware resources, so that applications do not have to pay attention to specific hardware access operations. For
In order for the compiler to better optimize the loop, we should try to reduce the judgment in the loop. One way is to integrate the judgment statement into the expression. For example:
For (int I = 0; I
If we need to add a judgment, only
1. macro definition. Constant Definition
# Define MATH_PI 3.14 void defineH () {// The macro replaces the constant corresponding to the macro in the compilation phase, so it is very fast; printf ("% f", MATH_PI );}
. method definition
// Define the
In JNI, we often encounter this scenario: to write some global variables in a. h file, and then all cpp files can be used. There is a. h file as follows:
/* * a.h * * Created on: 2014-4-16 * Author: Administrator */#ifndef A_H_#define A_H_int
I. Data Type:
In any programming language, the data type as a whole, the ANSI-C contains the types: int, double, char ......, Programmers are rarely satisfied with the data types provided by the language itself. A simple method is to construct a
At present, most IO analog I2c bus programs on the Internet are query methods, which wastes a lot of CPU cycles for cyclic waiting. The program in this article uses the timer interrupt to push the state machine to simulate I2C bus operations,
The
When testing program performance, we often need to obtain precise ns-level time to measure the performance of a program. The following describes how to obtain ns-level time in linux.
Use the clock_gettime function. The function prototype is as
Let's take a look at a line of code:
Const int * p = new int (10 );
The problem arises. The new address should be block heap memory, and the const constant should be stored in the static memory zone, is the memory pointed to by the pointer p in
Using C to generate random numbers is a common programming function task. Of course, it is not difficult to call two or three functions, but you know what the functions play, and how do they generate random numbers?Several Concepts
Random Number:
Typedef is a key word in C language. It defines a new name for a data type. The data types here include internal data types (int, char, etc.) and Custom Data Types (struct, etc ).
In programming, typedef is generally used for two purposes. One is to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.