Thread: Some array Q

  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
    Registered User
    Join Date
    Sep 2012
    Posts
    357
    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, 06:41 AM
  2. Replies: 2
    Last Post: 03-20-2012, 08:41 AM
  3. Replies: 9
    Last Post: 08-23-2010, 02:31 PM
  4. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  5. Replies: 1
    Last Post: 04-25-2006, 12:14 AM