[ create a new paste ] login | about

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

C++, pasted on Dec 29:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <stdlib.h>

template <int N>
inline void func(int *t) {
  t[N-1]=rand();
  func<N-1>(t);
}

template <>
inline void func<0>(int *t){}

int main()
{
        int     x[10] = {0};
        func<10>(x);

        for(int i=0;i<10;i++) printf("%d:%d\n", i, x[i]);
}


Output:
1
2
3
4
5
6
7
8
9
10
0:1189641421
1:596516649
2:1649760492
3:719885386
4:424238335
5:1957747793
6:1714636915
7:1681692777
8:846930886
9:1804289383


Create a new paste based on this one


Comments: