C Language Blog Job-pointers

Source: Internet
Author: User

First, the PTA experimental work problem 1:1. PTA Submission List

2. Design ideas (in code to indicate the deduction points)
定义整型变量i,count记录平均分,实型变量sum保存总分for i=0 to n sum = sum+*(s+i) i++平均分=sum/n;for i=0  to  n如果 *(s+i)大于等于平均分count++return count
3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.


    • At first want to let the pointer variable self-increment operation, but let it self-increment of the method is somewhat wrong, but also have self-added back not to the problem, has not been solved, know how to change
    • Forgetting to assign the initial value to sum and count,
    • The type of sum defines the error, it should be floating point, I define the int type, but I have (sum*1.0) divided by the n operation, the result is still wrong, the correct after the change
Topic 2: Find the maximum value and its subscript 1. PTA Submission List

2. Design ideas (in code to indicate the deduction points)
定义整型变量i用作循环,max返回最大值令 max=*a;for i=0  to n如果 max<*(a+i)max=*(a+i) *b=i存放大的数的下标i++return max
3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • Compile error Forget the seal number, the idea is clear, there is no problem.
Topic 3: Output month English name 1. PTA Submission List

2. Design ideas (in code to indicate the deduction points)
如果n>=1且n<=12switch(n)是某个月则返回该月的英文else返回 null

3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • Initially did not think directly with the switch statement to choose directly, with the method of defining the array, but did not assign an initial value to the array variable case, only the return of the null case is correct, and then refer to other people's approach to switch statements
    • Double quotation marks when the return character is added
Third, read the code (2 points)

    • Function: Find the longest string
    • Pros: Defines the character variable op to absorb the carriage return, avoids the error that the character array may bring, the thought is clear, the annotation is proper, the typesetting is also very good

Find two good code stickers to show and explain what the code is capable of and what are the advantages?
The code can be your classmate code, or it can be another place to find the code about C.

Iv. Summary of this week's study 1. Summarize what you learned this week.
    • The value that the string pointer points to is the address of the storage unit holding the first character of the string constant
    • When the printf function outputs a string, the array name, pointer, and string constants can be used as output parameters, the output parameters are given the starting position, and the '% ' control is ended
    • Some of the string-handling functions declared in String.h:
字符串复制函数:char *strcpy (char*s1.char*s2)把字符串s2的内容复制到s1,可简化为strcpy(s1,s2)s1必须是字符数组基地址,s2可以是字符数字名或字符串常量
字符串连接函数:stract(s1,s2)s1必须是字符数组基地址,s2可以是字符数字名或字符串常量s1中原有的结束符被放在连接后的结束位置上
字符串比较函数:strcmo(s1,s2)此时s1、2都可以是字符数组名或字符串常量从两个字符串的首字符开始,一次比较对应字符的asc码,直到遇到不同的字符或结束符若都相同  return 0else 返回第一个不同字符比较的差值
字符串长度函数:strrlen(s1)  可以返回有效字符的个数 ,即不包括结束符
    • Definition of the structure variable:
struct 结构名 {类型名 结构成员名1...类型名 结构成员名n }
    • Through the struct member operator "." A member can be referenced, and a struct variable of the same type can be directly assigned a value
    • When defining a nested definition of a struct type, you must first define the structure type of the member, and then define the main structure type
    • There are three ways to define a struct variable: a separate definition. Mixed definitions and untyped name definitions, note that the last one cannot define other struct variables of this type after this definition statement because the struct name is not given
    • Define structure array: Structure type an array group an array group length
    • A struct pointer can also be used as a function parameter, in which a struct variable passes each member value in the argument structure to the member of the formal parameter, and the struct pointer passes an address value.
2. List some of the wrong questions this week.


C Language Blog Job-pointers

Related Article

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.