Skip to Content

Revision of nseries from Fri, 30/12/2005 - 12:58pm

The revisions let you track differences between multiple versions of a post.

/* nseries complement the series program, this program reads a list of strings and adds an inceremneting postfix each time a string is read for instance it´ll take an input of foo foO fOO FOO and output foo1.gif foO2.gif fOO3.gif FOO4.gif

may be used to creat complex download lists

Alaa The Great

  1. /1/2002
  • /

using namespace std;

/* program takes 4 arguments 1-start of series,

  1. -number of digits (used to pad leading zeros)

and 3-a postfix string value to add after each increment

  • /

int main(int argc, char *argv[]) {

int count,pad; char a; string prefix; prefix=""; if (argc<4) { cout<<"need three arguments please"<<endl; return 1; }

do { a=getchar(); if (a=='\n'||a==EOF&&prefix!="") { cout<<prefix; if (count!=0) for(int k=pad; pow(10.0,(k-1))>count; k--) cout<<0; else for (int k=pad; k>1; k--) cout<<0; cout<<count<<postfix<<endl; count++; prefix=""; } if (a!='\n'&&a!=EOF) prefix=prefix+a; } while (a!=EOF);

return 0; }



Dr. Radut | book