Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 19th, 2005, 4:57 PM   #1
helldeamon
Newbie
 
Join Date: Jun 2005
Posts: 1
Rep Power: 0 helldeamon is on a distinguished road
Wink Help me

// VC6
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct read_with_vector_reader { };
struct read_with_native_stream { };

template <typename _T, typename _Trait = read_with_native_stream>
struct vector_reader {
vector<_T> &v;
vector_reader(vector<_T> &_v = vector<_T>()) : v(_v) { };
};

template <typename _T>
istream &operator >>(istream &is, vector_reader<_T, read_with_native_stream> &vr) {
for(vector<_T>::iterator it = vr.v.begin(); it != vr.v.end(); ++it)
is >> *it;
return is;
}

template <typename _T>
istream &operator >>(istream &is, vector_reader<_T, read_with_vector_reader> &vr) {
for(vector<_T>::iterator it = vr.v.begin(); it != vr.v.end(); ++it)
is >> vector_reader<_T::value_type>(*it);
return is;
}

void main(int ac, char *av[]) {
int n, m, x;
vector<int> vres;

freopen(ac > 1 ? av[1] : "zad.inp", "r", stdin);
freopen(ac > 2 ? av[2] : "zad.out", "w", stdout);
cin >> n >> m;
vector<vector<int> > varr(n, vector<int>(vector<int>(m)));
cin >> vector_reader<vector<int>, read_with_vector_reader>(varr);
cin >> x;
for(vector<vector<int> >::iterator it = varr.begin(); it != varr.end(); ++it) {
if (find(it->begin(), it->end(), x) != it->end())
vres.push_back(distance(varr.begin(), it) + 1);
}
cout << vres.size() << endl;
copy(vres.begin(), vres.end(), ostream_iterator<int>(cout, "\n"));
}


can someone translate this into c++ without these libraries(iostream,vector and algoritm ),using only stdio.h string.h conio.h and math.h
helldeamon is offline   Reply With Quote
Old Jun 19th, 2005, 5:24 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
One wouldn't actually translate it so much a rewrite it. Even if you have a handful of cash, I'd suggest you're probably in the wrong forum. I prostitute myself elsewhere. Of course, I can't speak for everyone.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 19th, 2005, 5:50 PM   #3
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
What else can one do wrong in a post? Sorry to behave like this but: your topic is wrong, your contents are wrongly posted, your formulation of the question is wrong and the question itself is wrong also.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Jun 19th, 2005, 6:30 PM   #4
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 599
Rep Power: 4 Ancient Dragon is on a distinguished road
Quote:
Originally Posted by helldeamon
can someone translate this into c++ without these libraries(iostream,vector and algoritm ),using only stdio.h string.h conio.h and math.h
it already IS c++. What you want is to rewrite that c++ into C. :eek:

And the subject of this thread -- "HELP ME" sounds more like a command than a request. I, for one, don't like being told that I have to help you, so I won't.
Ancient Dragon is offline   Reply With Quote
Old Jun 20th, 2005, 3:28 AM   #5
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
Also kinda sounds like homework/.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC