c# if语句不做某事

本文关键字:if 语句 | 更新日期: 2023-09-27 18:01:59

我试图写if语句不画任何东西,如果"跨"或"向下"小于或等于零。不太明白如何写它来停止draw_rect。出现问题了,尽管我设置了= 0

int horiz;
int vert;
int across;
int down;
char display_char;
void draw_rect ( void ) {
    //      If either of the width or height is less than or equal to zero,
    //      the function must not draw anything.

    draw_line( horiz, vert, across, vert, display_char );
    draw_line( horiz, down, across, down, display_char );
    draw_line( horiz, vert, horiz, down, display_char );
    draw_line( across, vert, across, down, display_char );
    if ( down > 0 ){
       ?????
    }   
int main( void ) {
    setup_screen();
    // draw a box.
    horiz = rand() % screen_width() / 2;
    vert = rand() % screen_height() / 2;
    across = 1 + rand() % (screen_width() - horiz - 1);
    down = 1 + rand() % (screen_height() - vert - 1);
    display_char = '@';
    draw_rect();
    show_screen();
    // draw a box with zero height.
    horiz = rand() % screen_width() / 2;
    vert = rand() % screen_height() / 2;
    across = 1 + rand() % (screen_width() - horiz - 1);
    down = 0;
    display_char = 'a';
    draw_rect();
    show_screen();


    timer_pause(5000);
    cleanup_screen();
    return 0;
}

c# if语句不做某事

这很简单:

void draw_rect ( void ) 
{
//If either of the width or height is less than or equal to zero,
//the function must not draw anything.
   if(across > 0 && down > 0)
   {
      draw_line( horiz, vert, across, vert, display_char );
      draw_line( horiz, down, across, down, display_char );
      draw_line( horiz, vert, horiz, down, display_char );
      draw_line( across, vert, across, down, display_char );
   }
}

换个角度想。