I want to print pattern like this, but it prints like second one?
*
* *
* * *
* * * *
* * * * *
enter image description here -- here is my script
*
* *
* * *
* * * *
* * * * *
CodePudding user response:
Your code is fine:
BEGIN
FOR i IN 1 .. 5 LOOP
FOR j IN i .. 4 LOOP
DBMS_OUTPUT.PUT(' ');
END LOOP;
FOR j IN 1 .. i LOOP
DBMS_OUTPUT.PUT('* ');
END LOOP;
DBMS_OUTPUT.PUT_LINE('');
END LOOP;
END;
/
It outputs:
*
* *
* * *
* * * *
* * * * *
Whatever IDE you are using may be stripping the leading whitespace.
CodePudding user response:
The output you've shown is a bit confusing, because if the first line is losing its leading whitespace then the rest of them should be too. But it depends on your client, as MTO said.
If you are using SQL*Plus (and similar) then you may just need to do:
set serveroutput on format wrapped