![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Posts: 1
Rep Power: 0
![]() |
// 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 |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
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 |
|
|
|
|
|
#4 | |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 599
Rep Power: 4
![]() |
Quote:
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. |
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|