Some array Q

This is a discussion on Some array Q within the C Programming forums, part of the General Programming Boards category; given 2 dimension array Code: int a[2][2]={1,1}, {2,2}; int b[2][2]={2,1}, {1,2}; int percentage; Question compared 2 array , printf how ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    2

    Question Some array Q

    given 2 dimension array
    Code:
    int a[2][2]={1,1},
                    {2,2};
    
    int b[2][2]={2,1},
                    {1,2};
    int percentage;
    Question compared 2 array , printf
    how many % are match ?

  2. #2
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    I don't understand the question.
    Code:
    while(!asleep) {
       sheep++;
    }

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    2
    mean 1st array is
    Code:
    A[2][2] {x,x}
            {x,x} // random input by user
    second array
    Code:
    B [2][2]{2,1},
            {1,2}//target by system
    printf (array a only match array b by xx% please retry to get correct 1)
    my question is how to calculate the percent?

  4. #4
    qny
    qny is offline
    Registered User
    Join Date
    Sep 2012
    Posts
    355
    Percentage = (number of interesting items) / (total number of items) * 100

    In your example, the number of interesting items is 2, the total number of items is 4 ... so the percentage is 2 / 4 * 100 = 50

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-09-2012, 07:41 AM
  2. Replies: 2
    Last Post: 03-20-2012, 09:41 AM
  3. Replies: 9
    Last Post: 08-23-2010, 03:31 PM
  4. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  5. Replies: 1
    Last Post: 04-25-2006, 01:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21