Friday, 6 February 2015

pattern 5

1 2*3 4*5*6 7*8*9*10 7*8*9*10 4*5*6 2*3 1 #include <stdio.h> void draw_line(int n); void draw_pattern(int n,int m); void draw_rpattern(int n,int m); void main() { } void draw_line(int n) { int i; for (i=0;i<n-1;i++ ) { printf("%d*",n); } printf("%d\n",n); } void draw_pattern(int n,int m) { if(n==1) draw_line(n); else { draw_pattern(n-1,m); draw_line(n); if(n==m) draw_rpattern(n,m); } } void draw_rpattern(int n,int m) { if(n==1) draw_line(n); else { draw_line(n); draw_rpattern(n-1,m); } }

No comments:

Post a Comment