Define an array type recursive with two types and some rules

Viewed 39

I hava an array with two types, which the odd index is always TypeA and the even index is always TypeB.

According to the description, the array always has even length, never have odd length.

The data structure of array must be so.

And this structure is from marijnh's orderedmap module.

// array
[A, B, A, B, A, B, ...]

// How to define it's type?
1 Answers

for this type of array it's better to define two arrays first for the first type and second for the second type but for example if it is char and int you can define it as a int and whenever you want to use it as a char in scanf use %d to scan ascii code of that and use %c in printf to print char of it

Related