1): If the third variable is not used, the values of the two variables A and B are exchanged (function is not allowed)
1) XOR (<== XOR or ???)
A = a xor B;
A = a xor B;
B = a xor B;
2) A + = B; B = A-B; A = A-B;
(2) do not use any conditional statements to calculate the maximum number of two integers? (Function is not allowed )?
Max = a + B-| a-B |;
3) How much space does struct student {long...; Char... float...} occupy?
See struct size-
4) define the data structure and write the program: Insert a node to the I position in a one-way linked list.
# Include <iostream. h>
# Include <malloc. h>
# Include <string>
Typedef struct linklist {
Int data;
Struct linklist * next;
} Node, * linklist;
/*************************************** *********************************/
/* Display the traversal of the linked list */
/*************************************** *********************************/
Void visitlinklist (linklist L)
{
Linklist V;
V = L-> next;
If (! (V) printf ("the linked list is empty/N ");
Printf ("/nheader node ");
While (V)
{
Printf ("-> % d", V-> data );
V = V-> next;
}
Printf ("/n completing linked list traversal/N ");
}
/*************************************** *********************************/
/* Insert a node after I position */
/*************************************** *********************************/
Void insertnode (linklist & L, int I)
{
Linklist H, P;
H = L;
While (H & (H-> data! = I ))
{
H = H-> next;
}
If (h)
{
P = (linklist) malloc (sizeof (node ));
// Cout <"input value for new node" <Endl;
// CIN> P-> data;
P-> DATA = 88;
P-> next = H-> next;
H-> next = P;
} Else {
Cout <"I not found" <Endl;
}
}