Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define WIDE 15
- #define HIGH 9
- #define SIZE 5
- //печать 4 одинаковых равносторонних прямоугольных треугольников(каждый из них уникальным образом развернут)
- //с отступом сверху и слева, введенным с клавиатуры
- void pr_stars(int,int,int,int,int,int);//top_gap,left_gap,HIGH,WIDE,SIZE,formula clue
- int main()
- {
- int i,j,arr[HIGH][WIDE],top_gap,left_gap,sum=0;
- printf("Enter (0-3) rows_gap,cols_gap: ");
- scanf("%d %d",&top_gap,&left_gap);
- pr_stars(top_gap,left_gap,HIGH,WIDE,SIZE,1);//last argument is a clue for triangle form specification
- pr_stars(top_gap,left_gap,HIGH,WIDE,SIZE,2);
- pr_stars(top_gap,left_gap,HIGH,WIDE,SIZE,3);
- pr_stars(top_gap,left_gap,HIGH,WIDE,SIZE,4);
- return 0;
- }
- void pr_stars(int t,int l,int h,int w,int s ,int clue)
- {
- int i,j,start,finish;
- for(i=0;i<h;i++)//1 1 star + 9 spaces
- {
- if(i<t||i>=t+s)
- {
- for(j=0;j<w;j++)
- printf("+");
- printf("\n");
- }
- else
- {
- for(j=0;j<w;j++)
- {
- switch(clue)//to set start and finish depending of clue
- {
- case 1: start = l;finish = l-t+i+1;break;
- case 2: start = l;finish = l+t+s-i;break;
- case 3: start = l+t+s-i-1;finish = l+s;break;
- case 4: start = l-t+i; finish = l+s;break;
- }
- printf("%c",(j>=start&&j<finish)?'*':'-');//
- }
- printf("\n");
- }//end of else
- }
- }
Add Comment
Please, Sign In to add comment