以上代码不可编译。请发布完整的示例。 我认为您打算使用scanf()而不是printf()作为第一个 。 你的州问题非常*模糊......解决方案是无限的。你 甚至可以忽略输入数字并产生rand() 或其他东西的结果。The above code is not compileable. Please post complete examples.I think you meant to use scanf() rather than printf() for the firstone.Your state problem is *very* vague... the solutions are infinite. Youcould even ignore the input numbers and produce the results of rand()or something. < snip> 你的州问题非常*模糊......解决方案是无限的。你甚至可以忽略输入数字并产生rand()或其他东西的结果。<snip> Your state problem is *very* vague... the solutions are infinite. You could even ignore the input numbers and produce the results of rand() or something. 不,他不能(如果我对问题的理解是正确的),如果 结果rand()产生两个输入 数字中的一个或其他(或者两个)。 这应该这样做: #include< stdio.h> #include< limits。 h> #include" thirdpartyerrormodule.h" void silly(unsigned int m,unsigned int n) { unsigned int x = UINT_MAX - m; unsigned int y = UINT_MAX - n; if(m == n){error( 输入错误 - 数字是重复的;); } / * x绝对不同于m(UINT_MAX是奇数)* / / * y绝对不同于n(UINT_MAX是奇数)* / / * m绝对不同于n(已经检查过)* / / * x肯定与y不同(因为m!= n)* / / * m可能等于y,在这种情况下x将等于n * / if(m == y) { m + = 2; / *仍然!= x,不再是== y,可能是== n * / n + = 2; / *仍然!= y,不再== x,不再== n * / } printf("%u%u% u%u \ n",m,n,x,y); } - Richard Heathfield Usenet是一个奇怪的地方 - dmr 29/7/1999 http://www.cpax.org.uk 电子邮件:rjh在上面的域名(但显然放弃了www)No, he can''t (if my understanding of the problem is correct), in case theresult of rand() produces one or other (or even both) of the two inputnumbers.This should do it:#include <stdio.h>#include <limits.h>#include "thirdpartyerrormodule.h"void silly(unsigned int m, unsigned int n){unsigned int x = UINT_MAX - m;unsigned int y = UINT_MAX - n;if(m == n) { error("input error - numbers are duplicates"); }/* x is definitely different from m (UINT_MAX is odd) *//* y is definitely different from n (UINT_MAX is odd) *//* m is definitely different from n (checked already) *//* x is definitely different from y (because m != n) *//* m might equal y, in which case x will equal n */if(m == y){m += 2; /* still != x, no longer == y, might be == n */n += 2; /* still != y, no longer == x, no longer == n */}printf("%u %u %u %u\n", m, n, x, y);}--Richard Heathfield"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.ukemail: rjh at above domain (but drop the www, obviously) 这篇关于一个简单的'C'问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 15:27