You can connect both floppy drives to a 34 pin ribbon cable. The mainboard or floppy controller goes to one the of the cable that is not at the twist. The B: drive goes to a connector on the same side of the twist as the controller/mainboard. The A: drive goes to a connector after the twist. Oftentimes, these cables have connectors is both the 5.25" and the 3.5" shape where you would connect the drives. See this picture for reference: https://raw.githubusercontent.com/wiki/keirf/ … bmpc_ribbon.jpg .
You can connect the hard drive and the CD drive to the same 40-pin ribbon cable. In case there are two 40-pin plugs (maybe with pin 20 missing as key pin, making it "39 pins") on the motherboard, you can also connect the CD drive and the hard drive with different 40-pin ribbon cables. These 40-pin cables are usually called "IDE cables".
In no case, you can connect a CD drive and a standard floppy drive to the same ribbon cable. The only exception is if you have an IDE or ATAPI floppy drive like the LS-120 drive (which I don't think applies to your system). Even if your CD drive has a 34 pin connector like a floppy drive, it can not be connected to the same controller as a floppy drive - it would need a special 34-pin CD interface card instead.