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

  • Home
  • SEARCH
  • 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 8090199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:38:53+00:00 2026-06-05T19:38:53+00:00

I’m having a problem with a part of code. It should work,since it is

  • 0

I’m having a problem with a part of code. It should work,since it is error free, and it has no logical problems since it does work on someone else pc, but on my computer the result is the same as the input.
code(runnable):

#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
class RAngle{
public:
   int x,y,l;
   RAngle(){}
   RAngle(int i,int j,int k){
      x=i,y=j,l=k;
   }
   bool operator<(const RAngle& rhs)const{
      if(l < rhs.l){
         return true;
        }
      return 0;
  }
  friend ostream& operator << (ostream& out, const RAngle& ra){
    out << ra.x << " " << ra.y << " " << ra.l;
    return out;
  }
  friend istream& operator >>( istream& is, RAngle &ra){
    is >> ra.x;
    is >> ra.y;
    is >> ra.l;
    return is ;
  }
};
void descrSort(vector <RAngle> &l){
    for(unsigned i=0; i<l.size();i++){
        cout<<l[i]<<endl;
    }
    cout << "==================" << endl;
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    for(unsigned i=0; i<l.size();i++){
        cout<<l[i]<<endl;
    }
}
void readData(vector <RAngle> &l){
   RAngle r;
   ifstream f_in;
   f_in.open("test.txt",ios::in);
   for(int i=0;i<10;++i){
      f_in >> r;
      l.push_back(r);
   }
}
int main(){
   vector <RAngle> a;
   readData(a);
   descrSort(a);

   return 0;
  }

DATA:

1 7 31
2 2 2
3 3 3
4 5 1
10 5 1
1 1 9
10 3 10
4 5 7
5 4 15
2 3 25
1 7 31

The output on other machine(only print part after, the descr sort):

1 7 31
2 3 25
5 4 15
10 3 10
1 1 9
4 5 7
3 3 3
2 2 2
10 5 1
4 5 1

on my computer(hoel output):

1 7 31

2 2 2

3 3 3

4 5 1

10 5 1

1 1 9

10 3 10

4 5 7

5 4 15

2 3 25

==================
1 7 31

2 2 2

3 3 3

4 5 1

10 5 1

1 1 9

10 3 10

4 5 7

5 4 15

2 3 25
  • 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-05T19:38:55+00:00Added an answer on June 5, 2026 at 7:38 pm

    This means your code has an error. C and C++ let things compile and run that actually have errors in them. Like this:

    int i;
    std::cout << i << std::endl;
    

    Will do different things on different machines. I would call it an error. The compiler won’t.

    Now as for where your error is, here is my “use a debugger” speech. Use a debugger. It will take you less time to use a debugger and have a decent chance of finding the error than it did for me to read your code to see if anything jumped out. Compile with -g. Google “gdb cheat sheet.” Run with gdb. Follow the cheat sheet. See where your code does something unexpected.

    Seems smart to do this on the machine that is giving the wrong output. And see where it’s doing something wrong.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters

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.