Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6583787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:27:16+00:00 2026-05-25T16:27:16+00:00

The question might be related more to math than to programming. I’ll explain the

  • 0

The question might be related more to math than to programming. I’ll explain the question by an example.
Let’s say I have an array with 100 items and I want to assign values to these items in such a way that the total of values in the first 80% of the items is 20% and the total of the values in the last 20% of the items is 80%. That is, the first 80% of the items get 20% and the rest get 80%. Knowing that the number of the items is determined at run time.

Is this possible?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:27:17+00:00Added an answer on May 25, 2026 at 4:27 pm

    Surely.

    Let total be 1, than 80% is 0.8. If 20 items sum up to 0.8, each of them gets 0.8/20 = 0.04.
    The rest 80 items get in total 0.2, each of them gets 0.2/80 = 0.01/4 = 0.0025.

    double[] items = new double[100];
    for (int i = 0; i < 20; i++)
        items[i] = 0.04;
    for (int i = 20; i < 100; i++)
        items[i] = 0.0025;
    

    The same applies for integers etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question might not seem programming related at first, but let me explain. I'm
This question might be naive as I'm new to ColdFusion programming. I have a
This question might be kind of elementary, but here goes: I have a SQL
The question might not be clear, so i will explain further. I saw some
I believe this question might have been previously attempted in 2006 on a different
This question is rather agnostic than related to a certain version control program. Assume
I hope this is programmer-related question. I'm in the hobby business of C# programming.
This is more of a philosophical question than a technical one. I'm about 40
Possibly related to my last question (note: different error code): Why might the fatal
My question is related class design. It is really hard to explain everything here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.