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 9134477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:40:02+00:00 2026-06-17T08:40:02+00:00

I have some file like following i need to remove the a multimap 3KHJG

  • 0

I have some file like following i need to remove the a multimap

 3KHJG 76  238
 3KHJG 86  238
 3GDMB 31  244
 3GDMB 31  247
 3GDMB 31  251
 3KOFA 21  336
 3KOFA 36  263

….

i need to get a file such as:

 3KHJG 81  238
 3GDMB 31  247

…..

// which keep the string key and calculate the avg of the next columns;

i have

 typedef struct S{
   int v1;
   int v2;
   ...
   }struct1;

struct1 s1;                 
//I parsed the old file and put them into a multimap and a set<string>;
multimap <string, s1> m;
multimap <string, s1>::iterator i;
set <string> pa_set;
int sumv1, sumv2;
int avgv1, avgv2;
for (set<string>:: iterator ip= pa_set.begin(); ip !=pa_set.end(); ip++)
{

  multimap <string, struct1> ::iterator i = m.find(*ip);

       int cnt=m.cout(*ip);
       if (ip != m.end())
      { 
        v1 =i->second.v1;
        v2 =i->second.v2;
        sumv1+=v1;
        sumv2+=v2;
        i++;
      }

      //calculate the avgv1 and avgv2;
}

however, if I used the if (){} it looks like i only iterator once?
how can I go through all the interators fullfill

    multimap<string,struct1> ::iterator i = m. find(*ip) && i != m.end() ;        

Thanks a lot!

  • 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-06-17T08:40:03+00:00Added an answer on June 17, 2026 at 8:40 am

    You can use the equal_range function that will give you pair of iterators to the range from which you’ll compute the averages.

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

Sidebar

Related Questions

I have some values in a configuration file (XML file) with some values like
I have text file with some stuff that i would like to put into
I have an array of file path components like this: [ ['some', 'dir', 'file.txt'],
I have a php file which has some variables like $name1, $name2... How can
I have an XML file that I would like to map some attributes of
I have to maintain some legacy codes,parts of it look like the following: /*
Say I have an XML file like the following: <holidays> <holiday1 val=New Years, 01/01,
I have a file that I need to reformat and remove extra blank lines.
This is some lines of text in a file. I need to remove certain
I have a VC++ application and in my application i have some basic file

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.