How many electrons are there in the pi-system of cyanogen?
Here is the structure of cyanogen



Each carbon has 4 valence electrons and each nitrogen has 5, for a total of ((4x2)+(5x2)) 18 electrons as you said.  Again, as you noted, 6 electrons are involved in sigma bonds, the 2 C-N sigma bonds and the one C-C sigma bond. Each nitrogen also has a lone pair of electrons and that accounts for (2x2) 4 more electrons.  That leaves 8 electrons to fill the 4 pi bonds.  Just like acetylene with 2 pi bonds, the two carbon-nitrogen triple bonds in cyanogen also have two pi bonds, with each pi bond holding 2 electrons.