Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- int main()
- {
- int b=0;
- int a=1;
- int n=0;
- int i=0;
- int j=0;
- int y=0;
- int i1=1;
- int p=0;
- printf("Enter row number:");
- scanf("%d",&n)
- printf("Enter a number:");
- scanf("%d"&p);
- for(i=1;i<=n;i++)
- {
- if((i%2)!=0)
- {
- for(j=1;j<=i;j++)
- {
- if(p==a)
- {
- printf("Row is %d and position is %d",i,j);
- }
- a--;
- }
- a++;
- }
- if((i%2)==0)
- {
- b=a+i1;
- i1=i1+2;
- for(j=1;j<i;j++)
- {
- if(p==b)
- {
- printf("Row is %d and position is %d",i,j);
- }
- b++;
- }
- b--;
- a=b+i1;
- }
- }
- getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment