Generation of lucky numbers out of given set of nos

amanbaua's Avatar, Join Date: Aug 2009
Light Poster
Code:
/*THE LOGIC BEHIND THIS PROGRAM IS THAT SUPPOSE THERE IS A SET OF NOS
1 2 3 4 5 6 7 8 9 10
FIRST EVERY 2ND NO IS DELETED WE GET
1 3 5 7 9
THEN EVERY 3RD NO IS DELETED
1 3 7 9
THEN EVERY 4TH NO IS DELETED
1 3 7
THEN EVERY 5TH NO IS DELETED
AS THER IS NO 5TH NO SO THE LUCKY NOS ARE
1 3 7*/
#include"stdio.h"
#include"conio.h"
void main()
{
  int i,k=0,p=2,t=0,n;int a[100];
  printf("enter the size of the array:\n");
  scanf("%d",&n);
  printf("enter the elements of the array\n");
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  printf(" The Sequence Of Lucky Nos Per Step Are:\n");
  for(i=0;i<n;i++)
  {
     printf("%d",a[i]);
     printf("\t");
  }

  while(1)
  {
     t=0;
    for(i=0;i<n;i++)
  {

     if(a[i]!=32767)
     {
        k++;
        if(k==p)
        {
          a[i]=32767;t++;
          k=0;
        }

      }
    }
        p++;k=0;
         if(t==0)
         {
              break;
         }
         printf("\n");
            for(i=0;i<n;i++)
        {
            if(a[i]!=32767)
          {
         printf("%d ",a[i]);
         printf("\t");
          }
        }
         printf("\n");



    }
     getch();
 }

Last edited by shabbir; 4Sep2009 at 22:12.. Reason: Code blocks
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Duplicate of http://www.go4expert.com/showthread.php?t=19295
Unless the code is different, I haven't checked for that.
Posting duplicate threads is a good way to get banned; please don't do that (unless getting banned is your aim of course).
0
amanbaua's Avatar, Join Date: Aug 2009
Light Poster
hey mr mentor both i mean 2 say both the article and the thread r posted by me
its d same amanbaua
understand
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
Quote:
Originally Posted by xpi0t0s View Post
Posting duplicate threads is a good way to get banned ....


Quote:
Originally Posted by amanbaua View Post
hey mr mentor both i mean 2 say both the article and the thread r posted by me
its d same amanbaua
understand
The last one you posted was transferred to the queries forum, it's not an article.
And, I think xpi0t0s perfectly understands the facts that :
(1) both are the same.
(2) both are posted by you.

======

Duplicate of http://www.go4expert.com/showthread.php?t=19295.

[[ Thread CLOSED ]]