tags: C/C++ c language c++ algorithm
I just wrote an algorithm question. I used double type data, and the output was %lf, but the result always reported an error. Later, I found out that I changed it to %f and it passed. After further research, I discovered this detail, so I did the following notes.
First, let's take a look at the output formats of scanf and printf:


Yes, you read that right, there is a distinction between float and double types in scanf, that is, the former is used%f, the latter is used%lf, but when it comes to printf, the uniform is%f, for this small detail, the compiler I use—clion in jetbrain seems to handle it automatically, and did not report an error to me, so I always thought that scanf and printf are the same processing method, but the algorithm problem At that time, the OJ system seems to be unable to deal with such problems, so it is best to follow the above standards in the future
I believe many of the students C ++ students will also encounter this problem, look at the following code: The result is of course the program is wrong. The error is wrong on the parameter of the inpu...
Today, write programs find a problem, Double type uses Printf ("% f") and printf ("% LF") to output normally, and Scanf must use% LF. Here, R, H, S is defined as Double type, SCANF...
1. What is CRLF and LF CRLF is the abbreviation of carriage return line feed; Chinese means carriage return line feed. LF is the abbreviation of line feed, which means line feed in Chinese. 2. Why sho...
1. Answer analysis (1) If in the C language compiler, int f(): ¡Indicates the return value int, and any number of parameters; int f(void): It means that the return value is int and no parameters...
original The difference between C language scanf() and gets() and printf() and puts() August 16, 2015 08:30:46 xingjiarong Reading number: 22447 First, scanf () and gets () 1.scanf() Header file: stdi...
1 printf Printf is output to the screen, nothing to say. 2 sprintf Printf is output to a string, which is described in detail below. (1) The declaration of the sprintf() function. (2) Parameters of th...
Take the following temperature conversion program as an example: Just double the quotes in the variable type that you want to enter the value, don't write anything extra; The variable to be assigned l...
C language scanf (), printf (), putchar (), getchar (), etc. using the difference: scanf () function and putchar () function is different, printf () function and getchar () function is different. the ...
forward from: printf () is most commonly used in console applications, and it is also very simple to use. Its parameters are format strings. Function prototype: printf (const char * format, [argument]...