Re: Оператори вибору switch-case незамінні?
Дякую, форумчане! З вашими підказками у мене вийшло отаке
#include <cs50.h>
#include <stdio.h>
//*Програма має вивести на екран піраміду заданої висоти, вирівняти її по правому краю*//
int main (void)
{
  int s, h, n;//*s-спейс, h-хештег, n-висота піраміди*//
   printf ("Whet is the height of the pyramid? \nGive me an between 1 and 23: ");//*Запитуємо яка висота піраміди*//
   scanf ("%d", &n);//*Вводимо висоту піраміди*//
  
  do 
  {
    if (n <= 0 || n >= 23)//*Перевіряємо, щоб висота була в заданих межах*//
    scanf ("%d", &n);//*Очікуємо введення коректної висоти*//
  }
  while (n <=0 || n >= 23);
  
   for ( s = 2; s < n+2; s ++)
   {
       for ( h = s; h <= n+1; h ++)
       printf (" ");
       
       for (h = 0; h < s; h ++)
       printf ("#");
       
       printf ("\n");
   }
       return 0;
}Як на мене, то працює. Але, програмка, що мене перевіряла, каже що не все так просто, і видає отакий вирок:
Uploading...
Checking.....................................................................
 mario.c exists
 mario.c compiles
 rejects a height of -1
   \ expected output, not a prompt for input
 handles a height of 0 correctly
   \ expected an exit code of 0, not a prompt for input
 handles a height of 1 correctly
   \ expected output, but not " ##\n"
 handles a height of 2 correctly
   \ expected output, but not "  ##\n ###\n"
 handles a height of 23 correctly
   \ expected output, not a prompt for input
 rejects a height of 24
   \ expected output, not a prompt for input
 rejects a non-numeric height of "foo"
   \ killed by server
 rejects a non-numeric height of ""
   \ expected output, not a prompt for input
Що вони з мене хочуть?