[C/C++]
Triangular.c
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i,k,e;
printf("Input number:");
scanf("%d",&e);
for(i=e;i>0;i--)
{
for(k=i;k>0;k--)printf("* ");
printf("\n");
}
system("pause");
return 0;
}
[MATLAB]
Triangular.m
clear all
e= input('Input number:');
for k = e:-1:1
for i = k:-1:1
fprintf('* ')
end
fprintf('\n')
end
Compile and Run
[C/C++]
Type the command
~$Triangular.exe
[MATLAB]
Open the m-file and press “F5”
Result should be like this:
******
*****
****
***
**
*
0 意見:
Post a Comment