Guest User

Untitled

a guest
Jan 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. int main()
  4. {
  5. int b=0;
  6. int a=1;
  7. int n=0;
  8. int i=0;
  9. int j=0;
  10. int y=0;
  11. int i1=1;
  12. int p=0;
  13.  
  14. printf("Enter row number:");
  15. scanf("%d",&n)
  16. printf("Enter a number:");
  17. scanf("%d"&p);
  18.  
  19. for(i=1;i<=n;i++)
  20. {
  21. if((i%2)!=0)
  22. {
  23. for(j=1;j<=i;j++)
  24. {
  25. if(p==a)
  26. {
  27. printf("Row is %d and position is %d",i,j);
  28. }
  29. a--;
  30. }
  31. a++;
  32. }
  33.  
  34. if((i%2)==0)
  35. {
  36. b=a+i1;
  37. i1=i1+2;
  38.  
  39. for(j=1;j<i;j++)
  40. {
  41. if(p==b)
  42. {
  43. printf("Row is %d and position is %d",i,j);
  44. }
  45. b++;
  46. }
  47. b--;
  48. a=b+i1;
  49. }
  50. }
  51. getch();
  52. return 0;
  53. }
Add Comment
Please, Sign In to add comment