#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <cmath>
#include <map>
usingnamespace std;
template <typename T> void prn_vec(std::vector < T >&arg, string sep="")
{
for (int n = 0; n < arg.size(); n++) {
cout << arg[n] << sep;
}
}
vector <int> id2tagnum(int id, int tgl ) {
// replicate
vector <int> Rep;
Rep.assign(tgl, id-1);
vector <int> nuMTag;
for ( int i=tgl-1; i>=0 ; i-- ) {
double pw = pow(4.00, double (i));
int fm = double(Rep[i])/pw;
int md = fm % 4;
nuMTag.push_back(md);
}
return nuMTag;
}
int main () {
int tagLength = 5;
for ( int i=1; i<=10; i++ ) {
cout << i << "\t";
vector <int> Result = id2tagnum(i,tagLength);
prn_vec<int>(Result);
}
}
It works fine in:
gcc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
But it doesn't work in:
gcc (GCC) 3.3.3 (SuSE Linux)
yielding this error:
1 2 3 4 5 6 7 8 9 10 11 12
test.cpp: In function `std::vector<int, std::allocator<int> > id2tagnum(int,
int)':
test.cpp:29: warning: initialization to `int' from `double'
test.cpp:29: warning: argument to `int' from `double'
test.cpp: In function `std::vector<char, std::allocator<char> >
tagnum2acgt(std::vector<int, std::allocator<int> >)':
test.cpp:43: error: `i' undeclared (first use this function)
test.cpp:43: error: (Each undeclared identifier is reported only once for each
function it appears in.)
test.cpp:43: error: `w' undeclared (first use this function)
How can I resolve the problem so that it can compile in all GCC version?