C 如何确保用户输入大于以前的用户输入?

C 如何确保用户输入大于以前的用户输入?,c,C,我需要让用户输入一个正数,然后再输入另一个正数。 第二个数字*2必须大于第一个数字。 以下是我所拥有的,但它不起作用: #include <stdio.h> #include <math.h> int main() { double radius; //radius of circle// double side_a; //side a of rectangle that will be asked// double num_pol; //num

我需要让用户输入一个正数,然后再输入另一个正数。 第二个数字*2必须大于第一个数字。 以下是我所拥有的,但它不起作用:

#include <stdio.h>
#include <math.h>

int main()
{
    double radius; //radius of circle//
    double side_a; //side a of rectangle that will be asked//
    double num_pol; //number of sides to polygon//
    double side_b; //side a of rectangle that will be calculated//
    double S_circ; //surface of cercle//
    double S_rect; //surface of rectangle//
    double S_pol; //surface of polygon//
    double P=3.1416; //the number pi//    
    double diameter; // the diameter pf the circle//
    do
    {
        printf_s("enter a value for a:");
        scanf_s("%lf", &side_a);
    } while (side_a < 0);
    do
    {
    printf_s("enter a value for r:");
    scanf_s("%lf", &radius);
    diameter=radius*2;
    } while (radius < 0 && diameter < side_a);
}
#包括
#包括
int main()
{
双半径;//圆的半径//
双面_a;//将被询问的矩形的a面//
double num_pol;//多边形的边数//
双面_b;//将要计算的矩形的a面//
双S_圈;//细胞表面//
double S_rect;//矩形的曲面//
double S_pol;//多边形的曲面//
双P=3.1416;//数字pi//
双倍直径;//圆的直径//
做
{
printf_s(“输入a:”的值);
扫描面(“%lf”和侧面);
}而(a侧<0);
做
{
printf_s(“输入r:”的值);
扫描单位(“%lf”和半径);
直径=半径*2;
}而(半径<0和直径
半径<0和直径
这是错误的

这里需要一个OR:
半径<0 | |直径

radius>0&&diameter>sid\u a

循环在
false
条件下退出


使用德摩根:
!(a&b)=a | | b

您能显示i/o和错误吗?没有输出,只有输入。没有错误。用户必须为ex:90输入pos num,然后为ex:55输入另一个pos num。如果他输入的数字小于90/2,程序必须再次请求输入一个数字。OK编辑代码