Asus written test: Basic knowledge

Source: Internet
Author: User

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;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.