MTK Shenzhen company embedded software engineer pen questions (including some answers)

Source: Internet
Author: User
MTK Shenzhen Embedded Software Engineer (volume B) 1.

#define pi 3.14
#define Area(R) pi*R*R
main()
{
 int r1=5,r2=2;
 double s=0;
 s=Area(r1-r2);
 printf("The area is %f",s);
}

Result: The area is 3.700000.

2. The int compare (int a, int B) function is defined as the function pointer P of the function: int (* p) (int, int); p = compare;

3. Find the output result

#include<stdio.h>
void sub(char*s,int num)
{
 int i ,j=num;
 char t;
 while(j-->1)
 {
   for(i=0;i<j;i++)
   {
     if(s[i]<s[i+1])
     {
       t=s[i];
       s[i]=s[i+1];
       s[i+1]=t;
     }
   }
 }
}
main()
{
 char *s="CEAeded";
 sub(s,6);
 printf("%s\n",s)
}

Output result: the program crashes during running,

// 4 ************************************* *********
// Exchange the values of two variables. The third variable is not used, that is, a = 3, B = 5.
// After B = 3, a = 5
Unsigned char a = 3, B = 5;


// 5 ************************************* *************
# Define N 100
Void GetMemory1 (char * p)
{
P = (char *) malloc (sizeof (char) * N );
Strcpy (p, "Have a good day! ");
}
Char * GetMemory2 (void)
{
Char p [] = "Have a good day! ";
Return p;
}
Void main (void)
{
Char * str1 = NULL, * str2 = NULL;
GetMemory1 (str1 );
GetMemory2 (str2 );
Printf ("\ nstr1: % s", str1 );
Printf ("\ nstr2: % s", str2 );

// 6 ************************************* *****************
// Construct a single-chain table with N nodes and return the head pointer of the linked list. The sequence of each node in the linked list is required.
// Contrary to the input sequence of node data, for example, input 1, 2, 3, 4, and 5, the linked list is
// Head-> 5 4 3 2 1, supplemental procedure
# Define N 10
Typedef struct Node
{
Int data;
Struct Node * next;
} NODE;
Int Get_Data (int I); // The definition is omitted.
Node * Create_u ()
{
Int I;
NODE * p, * Head = NULL;
For (I = 0; I <N; I ++)
{
VP = New NODE;
P-> Data = Get_Data (I );
________________;
________________;
}
Return Head;
}

It's actually a head plug-in.

// 7 ************************************* *********
// N node linked lists. Each node stores one character to determine whether the characters stored in the linked list are
// Symmetric center, that is, a B c B a or a B c B a. Supplementary procedure
Typedef struct Node
{
Int data;
Struct Node * next;
} NODE;
Bool Is_symmeic (NODE * head, * int n)
{
Char D [N];
Int I, d;
__________;
For (I = 0; I <d; I ++)
{
D [I] = head-> data;
Head = head-> next;
}
If (__________)
{
Head = head-> next;
}
While (head)
{
_______________;
If (D [I]! = Head-> data)
{
Return false;
}
Head = head-> next;
}
Return true;
}
// 8 *************************************
// The str function contains only uppercase and lowercase letters. The change_move (char * str) function is used to convert uppercase letters to uppercase letters * and
// Move to the front case and return the number *
// If AabBdcYY is changed to ***** abd, 5 is returned.
Int chang_move (char * str)
{
Int len, I, curstr =-1;
Len = strlen (str );
For (I = len-1; I> = 0; I --)
{
If (str [I]> = 'A' & str [I] <= 'Z ')
{
Str [I] = '*';
If (cursor =-1)
{
Cursor = I;
}
Else if (cursor> I)
{
_____________;
Str [I] = '*';
_____________;

}
}
Return ____________;
}
// 9 ************************************* **********
// Obtain the first public substring of two strings and return the substring
// For example, "a B c d e f g e h I" "a c d e f ** g e h I"
// The first one is "c d e f"; strcmp () is not allowed ()
Char * Maxf (char * str1, char * str2)
{
}

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.