cara ke 1
#include <stdio.h>
#include <stdlib.h>
int main()
{ int i,j;
int two_dim [3][5]={1 ,2 ,3 ,4 ,5 ,
10 ,20 ,30 ,40 ,50 ,
100,200,300,400,500};
for (i=0;i<3;i++){
for (j=0;j<5;j++){
printf("%6d",two_dim [i][j]);
}
printf("\n");
}
system("pause");
}
cara ke 2
#include <stdio.h>
#include <stdlib.h>
int main(){
int i,j;
int n[11]={0,1,2,3,4,5,4,3,2,1,0};
for(i=0;i<11;i++){
printf("%5d",n[i]);
for(j=1;j<=n[i];j++)printf("%c",'*');
printf("\n");
}
system("pause");
return(0);
}
0 komentar:
Posting Komentar