Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Programming output short sentences
Programming output short sentences
How does 1.c language output segment by segment? 1, pause with sleep function, and output one by one with pirntf %c parameter.

2. General:

# Including

# Including

# Including

int main()

{

Char c[]={ "Hello, China!" };

int I;

for(I = 0; I {

printf("%c ",c[I]);

Sleep (100); //Sleep 100 ms

}

printf(" \ n ");

Returns 0;

}

2.C language input and output statement U is unsigned, not binary.

There is no output binary format in C.

int b =- 1; //Original title A, later output B.

%d: It has a binary output with the symbol 10, so it is-1.

%x: 16 hexadecimal output, 16 hexadecimal has no negative form, so convert-1 into unsigned number, and then convert it into 16 hexadecimal, which is 0XFFFF (depending on your output, you may use 16 bit machine or.

% o: octal output, octal has no negative form, so-1 is also converted into unsigned number, and then converted into octal.

%u: unsigned 10 binary output. The unsigned number of-1 is 65535 (16-bit format).

Please write a program and output a sentence on the console: China welcomes you to do the c# program.

[static thread]

Static void Main(string[] Args)

Among them, (string[] Args) is the parameter you access in the console, and you can output the information you need by judging the number of Args.

example

[static thread]

Static void Main(string[] Args)

{

int iL = Args。 Length;

Console. WriteLine ("you entered" +iL. ToString()+" parameters ");

Console. read();

}

4. There are some input and output statements in C language. C language itself does not provide input and output statements, and its input and output are completed by a number of "standard input and output functions" in the C language function library.

When calling "standard input-output function", you should use a header file named "stdio.h" and put it at the beginning of the source program in the form of "# i nclude". File name suffix ". H "is the abbreviation of" head "and" #i nclude "is a precompiled command.

(# i nclude can be omitted when only "printf" function and "scanf" function are called. 1 Character input function getchar () [Function and usage of getchar function] [Function]: Enter a character from a terminal (or an input device implicitly designated by the system) (generally referred to as a keyboard), and its return value can be an accepted character or an integer, that is, the ASCII code of the character.

[Common format]: getchar () [Note]: 1, the getchar () function can only accept one character; 2. To call the getchar () function, you need to add a precompiled command at the beginning of the program; 3.getchar is a parameterless function, but the empty parentheses behind it cannot be omitted; 2 Character Output put char () [put char ()] [Function] The function of Putchar is to output a character [Common format]: Putchar (parameter) to the terminal (generally refers to display), and "parameter" is usually a character variable, a character code (integer variable) or the character itself. [Note]: (1) putchar (ch) function can only output one character; If the parameter is an integer, the characters whose ASCII value is the number are output.

(2) To call the putchar(ch) function, you should also add the precompiled command # i nclude (3) at the beginning of the program. The putchar (ch) function can also output some control characters. Other escape characters can also be output. Example: Enter a line of characters and count the number of letters, numbers, spaces and other characters contained in the line of characters.

# I include main(){ int letter = 0,figure=0,blank=0,other = 0; char c; Printf ("Please enter a string:"); while((c=getchar())! ='\n')// Read characters and stop reading {if((c & gt;; =' a'& & amp/amp; amp; amp; amp/amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; else if(c & gt; = ' 1 ' & amp; & ampc & lt='9')// If the number figure++ is read, it is; Else if(c==' ')// If blank++;+is read; Else // If characters other than++are read in; } printf ("The number of letters is %d\n", letters); Printf ("drawing number %d\n", drawing); Printf ("Number of blanks is %d\n", blank); Printf ("Other quantity is %d\n", other); }。

5. What are the output and input statements in C language? Putchar (output character) getchar (input character) printf (format output) scanf (format input) puts (output string) gets (input string).

%d output decimal shaping data according to actual length.

%md .m is the width of the specified output field. If the number of digits is less than m, the left side is filled with spaces; if it is greater than m, it is actually output. For example: printf ("%4d, %4d, a, b "); When a= 123b= 12345, the output is empty 123, 12345.

%ld is the output long shaping data.

O is a format character. Octal output

X is a format character. Output in 16.

U is a format character used to output unsigned numbers and 10 decimal output.