[ create a new paste ] login | about

Link: http://codepad.org/ZEjN0Y0u    [ raw code | output | fork ]

C++, pasted on May 5:
#include <string>
#include <iostream>
using namespace std;

int main(){
    size_t i, j; 
    string srow = "1234567890123456789";
    string ssub = "<sub text>";
    string sout;
    cout<<"text row : "<<srow<<endl;
    cout<<"text sub : "<<ssub<<endl;
    for( j = 2 + (i = 0); i < srow.size(); i++ )
    {
        if( i == j )
        {
            j = j * 2;
            sout += ssub;
        }
        sout += srow[i];
    }
    cout<<"text out : "<<sout<<endl;
    return 0;
}


Output:
1
2
3
text row : 1234567890123456789
text sub : <sub text>
text out : 12<sub text>34<sub text>5678<sub text>90123456<sub text>789


Create a new paste based on this one


Comments: