C Language Blog Job--structure

Source: Internet
Author: User
Tags time and seconds

First, the PTA experimental work title 1:6-4 structure array sorted by total score 1. PTA Submission List

2. Design Ideas
* void calc(struct student *p,int n) //传结构体地址和数组的长度,功能是求和* 定义变量i用于循环* for i=0至n-1    p[i].sum =p[i].score[0]+p[i].score[1]+p[i].score[2]  //求和 end* void sort(struct student *p,int n)  //功能是将成绩总和从高到低对这组数据进行排序* struct student x* 定义变量 i,j,temp,t;//ij用于循环* emp等于(p+i)->sum;   //给temp赋值 * for j从i+1;j至n-1;   //选择排序法   if((p+j)->sum大于temp){  temp等于(p+j)->sum;  t=j;end *   *(p+i)赋值给x    *(p+t)赋值给*(p+i)    x赋值给*(p+t)
3. Code

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

    • This question is no problem, initially with the above will be the structure of the exchange, and then review the teacher's PPT, found that the exchange structure as long as there is a transitional structure in the middle can be,
      Shame, knowledge is missing.
Topic 2:7-2 Time Conversion

2. Design Ideas
* struct time   //设置时间的信息  { int hour,minute,second; int n; };//该结构体表示时间,和增加的时间* 定义变量ij用于循环,sum用于总秒,数组a[4]用于存放增加后的时分秒  还有struct time times* 输入时分秒,还有n* sum=times.n+times.hour*3600+times.minute*60+times.second;  //总秒 * do{    x[++i]等于sum%60;  //求时分秒         sum等于sum/60;    }直到sum对于0* for i从2开始直到为0  如果i对于2  那么a[i]>24 ,则a[i]/=24  如果a[i]x小于10,则在%d前加上0  否则直接输出按%d输出
3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • There's no problem with this question.
Title 3:7-6 the entry and display of the Address Book 1. PTA Submission List

2. Design Ideas
* struct information{    char name[11];    char born[11];    char sex[2];    char number1[19];    char number2[19];  };//朋友的姓名、出生日期、性别、固定电话号码、移动电话号码* 定义变量ij用于循环,n,k,t* 输出n,定义数组结构体a[n]* for i从0开始至n-1  scanf("%s%s%s%s%s",a[i].name,a[i].born,a[i].sex,a[i].number1,a[i].number2);  //输值* 输出k* 定义数组b[k]* for i从0开始至k-1 输入b[k] end* for i从0至k-1* 如果b[k]大于等于0且小于等于n-1  t等于b[k]  printf("%s %s %s %s %s\n",a[t].name,a[t].number1,a[t].number2,a[t].sex,a[t].born);  //输出 * 否则输出 Not Found end
3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • In fact, this problem has just begun my thinking in the birth date is not used in character type, and then half found to write not to go on, only to convert ideas all with character type to do.

This is because the array sex only defines one cause, without debugging, debugging does not go down.

This problem is caused by the small array of characters I defined at the beginning.

Second, this week's topic set PTA Final ranking.

Third, read the Code 5-5 time conversion
    • Outputs the time value after n seconds for a given time in HH:MM:SS format (more than 23:59:59 hours from 0 o'clock).
    • Input format: The input gives the start time in HH:MM:SS format in the first line, and the second line gives the number of seconds N (<60).
    • Output format: The output gives the result time in HH:MM:SS format in a row.
    • This code is similar to my idea, which is stored in the array for time and seconds, and then returned with a function.

      7-6 entry and display of contacts
    • A record in your address book contains the following basic information: Your friend's name, date of birth, gender, fixed phone number, mobile phone number. The subject asks to write the program, enter N records, and display any one record according to the requirement.
    • Input format: The input is given a positive integer n (≤10) on the first line, followed by n lines, each line is given a record in the format name of the birthday gender landline phone. Where the name is a non-empty string of no more than 10 characters, does not contain a space; birthdays are given in the format of YYYY/MM/DD; The gender uses m to denote "male", "f" means "female", and the fixed and mobile phones are not more than 15 consecutive digits, which may appear before +.
    • After the Address book entry is completed, the last line gives a positive integer k, and then a K integer indicating the record number to query (from 0 to n?1 sequential number). The numbers are separated by a space.
      Output format: For each record number to be queried, the record is output in one row according to the name of the phone's sex birthday. To query for a record that does not exist, the output is not Found.
    • This code I chose it because I mentioned earlier I used to define the date with int, do not come out, this code about the output date using%04d/%02d/%02d, let me understand%md deeper.

Iv. Study Summary of the Week 1. Summarize what you learned this week. structure, the common body, enumeration, the construction data type characteristics.
    • A struct can have data of a struct type, a type of a common body. Each member of a struct is used to represent a property of a particular transaction and can be assigned an initial value.
    • A common body is a constructed type of multivariate shared storage space that allows several different variables to share the same storage space. (The same storage space can store different types of data).
      It cannot be assigned an initial value, and space equals the space occupied by the largest member.
    • An enumeration type is a value of a variable that can be listed all, and the value of a variable is defined in the definition after an enumeration variable is defined.
      The difference between it and the struct, the common body is that the enumeration element is a constant and can only be assigned at the definition stage.
Principle of recursive function
    • Baidu a bit of information, may not be very comprehensive, so-called recursive function, is constantly calling itself. Each time a recursive call is performed,
      Stack the value parameters of the recursive function with the current value of the local variable and the return address after the call. Had a boundary condition, he would not call the
      Then release the stored value like a spring.
2. List some of the wrong questions this week

The original answer to this question is 15, and then want to debug to see how the function go, to run on the dev, found that can not, the choice is wrong.

C Language Blog Job--structure

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.