Use C # To insert the header and footer in word,
// Insert footer
[Csharp]View plaincopyprint?
- Public void InsertFooter (string footer)
- {
- If (ActiveWindow. ActivePane. View. Type = WdViewType. wdNormalView |
- ActiveWindow. ActivePane. View. Type = WdViewType. wdOutlineView)
- {
- ActiveWindow. ActivePane. View. Type = WdViewType. wdPrintView;
- }
- ActiveWindow. View. SeekView = WdSeekView. wdSeekCurrentPageFooter;
- This. Application. Selection. HeaderFooter. LinkToPrevious = false;
- This. Application. Selection. HeaderFooter. Range. ParagraphFormat. Alignment = WdParagraphAlignment. wdAlignParagraphCenter;
- ActiveWindow. ActivePane. Selection. InsertAfter (footer );
- // Jump out of the header and footer settings
- ActiveWindow. View. SeekView = WdSeekView. wdSeekMainDocument;
- }
Methods on msdn
[Csharp]View plaincopyprint?
- Foreach (Word. Section wordSection in this. Application. ActiveDocument. Sections)
- {
- Word. Range footerRange = wordSection. Footers [Word. WdHeaderFooterIndex. wdHeaderFooterPrimary]. Range;
- FooterRange. Font. ColorIndex = Word. WdColorIndex. wdDarkRed;
- FooterRange. Font. Size = 20;
- FooterRange. Text = "footer and footer ";
- }
- Foreach (Word. Section section in this. Application. ActiveDocument. Sections)
- {
- Word. Range headerRange = section. Headers [Word. WdHeaderFooterIndex. wdHeaderFooterPrimary]. Range;
- HeaderRange. Fields. Add (headerRange, Word. WdFieldType. wdFieldPage );
- HeaderRange. ParagraphFormat. Alignment = Word. WdParagraphAlignment. wdAlignParagraphRight;
- }
C language ^ how to use
A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010
B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011
^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.
//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].
How to judge prime numbers using C language
A prime number is a number that cannot be divisible by any integer except 1 and itself. For example, 17 is a prime number because it cannot be 2 ~ Any integer in 16. Therefore, to determine whether an integer m is a prime number, you only need to set m to 2 ~ M-1 no integer can be divisible, m is a prime number.
In addition, the judgment method can be simplified. M does not need to be 2 ~ Remove each integer between the numbers expressed as 1 and 2 ~ √ Remove each integer between m. If m cannot be 2 ~ √ Any integer across m, m must be a prime number. For example, to determine whether 17 is a prime number, you only need to enable 17 to be 2 ~ Since each integer between 4 cannot be divisible, 17 is a prime number. (Cause: If m can be 2 ~ If any integer is divisible between expressed on and off, one of the two factors must be less than or equal to √ m, and the other one must be greater than or equal to √ m. For example, 16 can be divided by 2, 4, 8, 16 = 2*8, 2 less than 4, 8 greater than 4, 16 = 4*4, 4 = √ 16, so only 2 ~ There is no factor between 4)
# Include <stdio. h>
# Include <math. h>
Void main ()
{
Int m, I, k;
Printf ("enter an integer :");
Scanf ("% d", & m );
K = (int) sqrt (m );
For (I = 2; I <= k; I ++)
If (m % I = 0)
Break;
If (I> k)
Printf ("% d is a prime number. \ N ", m );
Else
Printf ("% d is not a prime number. \ N ", m );
}