Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1

    Default REVERSING Numbers


    #include<stdio.h>
    #include<conio.h>

    main()
    {

    int enter[20],input;
    int i,j,t;

    printf("Enter How Many Number : ");
    scanf("%d",&input);


    for( i=0;i<=input-1;i++)
    { printf("\nInput %d : ",i+1);
    scanf("%d",&enter[i]);
    }
    printf("\nNumber Input are : ");
    for( i=0;i<=input-1;i++)
    { printf("\t %d",enter[i]); }


    for(i=input-2;i>=0;i--){
    for(j=0;j<=i;j++){
    if(enter[j]<enter[j+1])
    {
    t=enter[j];
    enter[j]=enter[j+1];
    enter[j+1]=t;
    }
    }
    }
    printf("\n\nSorted is: ");
    for( i=0;i<=input-1;i++)
    { printf("\t %d",enter[i]); }
    getch();

    }

  2. #2

    Default Re: REVERSING Numbers

    UP TANI PARA SA MGA CLASSMATES SA DATA STRUCTURE !!! \m/

  3. #3

    Default Re: REVERSING Numbers

    Unsa ni? Assignment?

    Unsay expected output?

  4. #4

    Default Re: REVERSING Numbers

    classmate, mana ka sa assignment?.. ako mana ko tara akoa ai...

    Code:
    #include <conio.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    #define FALSE 0
    #define TRUE 1
    
    int main(int* array, int count, int isReverse)
    {
      int numCount = 0;
      int* container = NULL;
    
      if(isReverse != TRUE && isReverse != FALSE)
      {
    	  main(NULL, 0, FALSE);
    	  getch();
    	  return 0;
      }
    
      if (array != NULL && count < 1)
        return 0;
    
      if (array == NULL)
      {
    	  printf("Number Count:>");
    	  scanf("%d", &numCount);
    	  container = (int*) malloc(numCount*sizeof(int));
    	  return main(container, numCount, 0) + main(container, numCount, TRUE);
      }
    
      if (isReverse == TRUE)
      {
        printf("\n%d", array[count - 1]);    
    	return main(array, count - 1, TRUE);
      }
      
      main(array, count - 1, isReverse);
      printf("Input item %d:>", count);
      scanf("%d", & array[count - 1]);
      return 0;
    }
    Last edited by fixyourself; 09-13-2011 at 11:28 AM.

  5. #5

    Default Re: REVERSING Numbers

    input

    1 2 3 4 5

    output

    5 4 3 2 1

    hehe ako g post dri kay d pde USB sa amo school , and block ang facebook. hahahh. and mga email.. heheh

  6. #6

    Default Re: REVERSING Numbers

    Quote Originally Posted by mediaskare View Post
    input

    1 2 3 4 5

    output

    5 4 3 2 1

    hehe ako g post dri kay d pde USB sa amo school , and block ang facebook. hahahh. and mga email.. heheh
    classmate, ok ra nko imo copyhon ako answer..

  7. #7

    Default Re: REVERSING Numbers

    na pass nmn nko classm8 nxt time mangayo ko nmo answer hahhaha... thx

  8. #8

    Default Re: REVERSING Numbers

    Quote Originally Posted by mediaskare View Post
    na pass nmn nko classm8 nxt time mangayo ko nmo answer hahhaha... thx
    wai blema na classmate. bsta siguroa lang kasabot ka g unsa..

  9. #9

    Default Re: REVERSING Numbers

    Pseudo:

    Code:
    Input:  n
    (1) Initialize m = 0
    (2) Loop while n > 0
         (a) Multiply m by 10 and add remainder of num
              divide by 10 to rev_num
                   m = m*10 + n%10;
         (b) Divide n by 10
    (3) Return m
    In effect:

    Code:
    int reverser(int n)
    {
        int m = 0;
        while(n > 0)
        {
            m = m*10 + n%10;
            n /= 10;
        }
        return m;
    }
    tada! recursive solution! O(log(n)) ftw!

  10. #10

    Default Re: REVERSING Numbers

    haha... tan awn nato bai, dawaton ba sa iyang maestra atong mga solution. haha

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. PERSONALITY TEST and BIRTH NUMBER
    By SPRINGFIELD_XD_40 in forum General Discussions
    Replies: 116
    Last Post: 11-26-2015, 11:38 AM
  2. Number of gfs/bfs?
    By Perfect_Guy in forum "Love is..."
    Replies: 518
    Last Post: 08-10-2015, 05:52 PM
  3. IMEI NUmber Analysis
    By chanbri in forum Gizmos & Gadgets (Old)
    Replies: 9
    Last Post: 06-09-2011, 07:23 PM
  4. reverse psycology....
    By neishan731 in forum "Love is..."
    Replies: 36
    Last Post: 08-23-2006, 08:27 AM
  5. LF: Nalusuan beach resort contact number?
    By kloos in forum Sports & Recreation
    Replies: 3
    Last Post: 06-20-2006, 12:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top