Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 10
- //работает, но куча вопросов (почему двойка последняя?
- //почему без последнего елсе не работает как надо?
- //остальные вроде помечены вопросы
- int main()
- {
- int i,j,n,y,arr[N][2*N-1] = {0};
- int curr, left, right;//pseudonames for array elements
- char ch = '#';
- y = 5;
- printf("%d\n",(y>10)? (y>3)? 1:10:100);//100 second,not ok!
- printf("%d\n",(y<10)? (y>3)? 1:10:100);//1 first ok
- printf("%d\n",(y>10)? (y<3)? 1:10:100);//100 third ok
- arr[0][N-1]=1;//fillling first row
- arr[1][N-2]=arr[1][N]=1;//filling second row
- for(i=2;i<N;i++)
- {
- for(j=0;j<2*N-1;j++)
- {
- left = arr[i-1][j-1];
- right = arr[i-1][j+1];
- if(left && right)
- curr = left + right;
- else if(left)
- curr = left;//is it better to use "curr = 1" here?
- else if(right)
- curr = right;
- else
- curr = 0;
- arr[i][j] = curr;//puts current value into array element
- if(i==9&&j==9)
- printf("%d 9&&9\n\n",arr[i][j]);
- }
- }
- for(i =0;i<N;i++)
- {
- for(j=0;j<2*N-1;j++)
- {
- if(arr[i][j])
- printf("%4d",arr[i][j]);
- else
- printf(" ");
- }
- //putchar( (arr[i][j])? arr[i][j] :' ');
- //printf("%4s",(arr[i][j])? (char *) arr[i][j] : " " );
- //printf("%*c\n",ch);
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement