user-0 提问: 求解不对啊，哪里的问题呢？

回复:
user: user-1
content: printf里面的%和变量的一一对应关系 scanf里面的%和变量以及变量前加不加&的一一对应关系 是C代码中非常容易出错的地方，而且通常编译还不出错。 所以在编译源代码之前值得专门仔细检查一遍甚至多遍。  scanf Type Field Characters The type character is the only required format field; it appears after any optional format fields. The type character determines whether the associated argument is interpreted as a character, string, or number.  Table R.8   Type Characters for scanf functions  Character  Type of Input Expected Type of Argument  c When used with scanf functions, specifies single-byte character; when used with wscanf functions, specifies wide character. White-space characters that are ordinarily skipped are read when c is specified. To read next non–white-space single-byte character, use %1s; to read next non–white-space wide character, use %1ws. Pointer to char when used with scanf functions, pointer to wchar_t when used with wscanf functions.  C When used with scanf functions, specifies wide character; when used with wscanf functions, specifies single-byte character. White-space characters that are ordinarily skipped are read when C is specified. To read next non–white-space single-byte character, use %1s; to read next non–white-space wide character, use %1ws. Pointer to wchar_t when used with scanf functions, pointer to char when used with wscanf functions.  d Decimal integer. Pointer to int.  i Decimal, hexadecimal, or octal integer. Pointer to int.  o Octal integer. Pointer to int.  u Unsigned decimal integer. Pointer to unsigned int.  x Hexadecimal integer. Pointer to int.  e, E, f, g, G Floating-point value consisting of optional sign (+ or –), series of one or more decimal digits containing decimal point, and optional exponent (“e” or “E”) followed by an optionally signed integer value. Pointer to float.  n No input read from stream or buffer. Pointer to int, into which is stored number of characters successfully read from stream or buffer up to that point in current call to scanf functions or wscanf functions.  s String, up to first white-space character (space, tab or newline). To read strings not delimited by space characters, use set of square brackets ([ ]), as discussed following Table R.7. When used with scanf functions, signifies single-byte character array; when used with wscanf functions, signifies wide-character array. In either case, character array must be large enough for input field plus terminating null character, which is automatically appended.  S String, up to first white-space character (space, tab or newline). To read strings not delimited by space characters, use set of square brackets ([ ]), as discussed preceding this table. When used with scanf functions, signifies wide-character array; when used with wscanf functions, signifies single-byte–character array. In either case, character array must be large enough for input field plus terminating null character, which is automatically appended.    The types c, C, s, and S are Microsoft extensions and are not ANSI-compatible.   Thus, to read single-byte or wide characters with scanf functions and wscanf functions, use format specifiers as follows.  To Read Character As Use This Function With These Format Specifiers  single byte scanf functions c, hc, or hC  single byte wscanf functions C, hc, or hC  wide wscanf functions c, lc, or lC  wide scanf functions C, lc, or lC    To scan strings with scanf functions, and wscanf functions, use the prefixes h and l analogously with format type-specifiers s and S.  scanf Width Specification width is a positive decimal integer controlling the maximum number of characters to be read from stdin. No more than width characters are converted and stored at the corresponding argument. Fewer than width characters may be read if a white-space character (space, tab, or newline) or a character that cannot be converted according to the given format occurs before width is reached.  The optional prefixes h, l, I64, and L indicate the “size” of the argument (long or short, single-byte character or wide character, depending upon the type character that they modify). These format-specification characters are used with type characters in scanf or wscanf functions to specify interpretation of arguments as shown in the Table R.7. The type prefixes h, l, I64, and L are Microsoft extensions and are not ANSI-compatible. The type characters and their meanings are described in Table R.8.  Table R.7   Size Prefixes for scanf and wscanf Format-Type Specifiers  To Specify Use Prefix With Type Specifier  double l e, E, f, g, or G  long int l d, i, o, x, or X  long unsigned int l u  short int h d, i, o, x, or X  short unsigned int h u  __int64 I64 d, i, o, u, x, or X  Single-byte character with scanf h c or C  Single-byte character with wscanf h c or C  Wide character with scanf l c or C  Wide character with wscanf l c, or C  Single-byte – character string with scanf h s or S  Single-byte – character string with wscanf h s or S  Wide-character string with scanf l s or S  Wide-character string with wscanf l s or S    Following are examples of the use of h and l with scanffunctions and wscanf functions:  scanf( "%ls", &x );    // Read a wide-character string wscanf( "%lC", &x );    // Read a single-byte character  To read strings not delimited by space characters, a set of characters in brackets ([ ]) can be substituted for the s (string) type character. The corresponding input field is read up to the first character that does not appear in the bracketed character set. If the first character in the set is a caret (^), the effect is reversed: The input field is read up to the first character that does appear in the rest of the character set.  Note that %[a-z] and %[z-a] are interpreted as equivalent to %[abcde...z]. This is a common scanf function extension, but note that the ANSI standard does not require it.  To store a string without storing a terminating null character ('\0'), use the specification %nc where n is a decimal integer. In this case, the c type character indicates that the argument is a pointer to a character array. The next n characters are read from the input stream into the specified location, and no null character ('\0') is appended. If n is not specified, its default value is 1.  The scanf function scans each input field, character by character. It may stop reading a particular input field before it reaches a space character for a variety of reasons:   The specified width has been reached.   The next character cannot be converted as specified.   The next character conflicts with a character in the control string that it is supposed to match.    The next character fails to appear in a given character set.  For whatever reason, when the scanf function stops reading an input field, the next input field is considered to begin at the first unread character. The conflicting character, if there is one, is considered unread and is the first character of the next input field or the first character in subsequent read operations on stdin.

user: user-2
content: d = 0 的判断写错了  #include<stdio.h> #include<math.h>  double a,b,c,d;  void big  (double m,double n,double l); void small(double m,double n,double l); void equal(double m,double n);   int main(void) { 	printf("please input three number:\n"); 	scanf("%lf %lf %lf",&a, &b, &c); 	 	d = b * b - 4.0 * a * c; //b*b -4ac  	printf("%7.2lf\n", d);  	 	if (d < 0) 	{ 		small(a, b, d); 	} 	else  	{ 		if(0 == d) 	 		equal(a,b); 		else 			big(a,b,d);  	} 	 	return 0; }   void big(double m,double n,double l) { 	double x1,x2; 	x1=(-n+sqrt(l))/(2.0*m); 	x2=(-n-sqrt(l))/(2.0*m); 	printf("X1=%5.2f,X2=%5.2f\n",x1,x2); } void small(double m,double n,double l) { 	printf("wujie\n"); }  void equal(double m,double n) { 	double x; 	x=(-n)/(2.0*m); 	printf("X=%5.2f\n",x);  }

user: user-0
content: 引用 2 楼 lgbxyz 的回复:d = 0 的判断写错了  #include<stdio.h> #include<math.h>  double a,b,c,d;  void big  (double m,double n,double l); void small(double m,double n,double l); void equal(double m,double n);   int main(void) { 	printf("please input three number:\n"); 	scanf("%lf %lf %lf",&a, &b, &c); 	 	d = b * b - 4.0 * a * c; //b*b -4ac  	printf("%7.2lf\n", d);  	 	if (d < 0) 	{ 		small(a, b, d); 	} 	else  	{ 		if(0 == d) 	 		equal(a,b); 		else 			big(a,b,d);  	} 	 	return 0; }   void big(double m,double n,double l) { 	double x1,x2; 	x1=(-n+sqrt(l))/(2.0*m); 	x2=(-n-sqrt(l))/(2.0*m); 	printf("X1=%5.2f,X2=%5.2f\n",x1,x2); } void small(double m,double n,double l) { 	printf("wujie\n"); }  void equal(double m,double n) { 	double x; 	x=(-n)/(2.0*m); 	printf("X=%5.2f\n",x);  }   scanf("%f%f%f",&a, &b, &c);改成scanf("%lf %lf %lf",&a, &b, &c);即可成功，为什么？

user: user-3
content: 编译没有问题，是代码逻辑问题吧，自己单步调试来跟踪