C Language Blog Job--structure

Source: Internet
Author: User

First, the PTA experimental work problem 1:6-1 calculation two complex number of the product 1. PTA Submission List (to submit list, not result)

2. Design ideas (pseudo-code or flowchart)
struct complex{    int real;    int imag;};//该结构体表示复数的实部和虚部。    定义一个结构体变量 product表示相乘后的复数    product.real(表示新复数的实部)=一个实部乘上另一个数的实部 - 一个数的虚部*另一个数的虚部    product.imag(新复数的虚部)=(x.real*y.imag)+(x.imag*y.real);    返回 product;
3. Code (note,,,. Do not paste on the blog. No need to use ... syntax to render)

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

The difficulty of this problem is how to express the new complex number, at the beginning of the thought for a long time, do not know how to direct the whole
The plural expression comes out, later changed a train of thought, is calculates the real part and the imaginary part respectively.

The topic 2:7-1 calculates worker's salary 1. PTA Submission List (to submit list, not result)

2. Design Ideas
struct staff{    char name[11];    float jbear;    float fdear;    float cost;    float income;}该结构体分别表示职工的姓名,基本收入,浮动收入,发费,和总收入定义一个 n 表示查询的员工数输入 n定义结构体变量  s[n]    for i=0 to i=n-1    输入 对应员工的姓名,基本收入,浮动收入,发费    总收入=基本收入+浮动收入-发费。    end for     for i=0 to i=n-1    输出  对应的姓名和总收入  
3. Code (note,,,. Do not paste on the blog. No need to use ... syntax to render)

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

On the subject, in fact, I have to live again, hahaha, do not understand what to say, pay attention to the point, it is mainly to
The use of structural arrays, the following table is focused on below, there is no difficulty.

Topic 3: Entry and display of contacts 1. PTA Submission List (to submit list, not result)

2. Design Ideas
struct infor{    int year,month,day;    char name[20];    char c;    char gd[20],yd[20];};  这个结构体是表示出生的时间月份,姓名,性别,固定电话,移动电话。定义一个n,表示下面将要输入n个人的信息。定义一个结构体数组   s[n]for i=0 to i=n-1;   输入 姓名,性别,固定电话,移动电话   end for 再定义 y m y表示查询的次数,   m表示查询的编号for i=0 to i=y-1    输入m    如果 m<=n-1&&m>=0           {              输出  姓名,固定电话,移动电话,性别,和出生年月日。         }    否则   输出     Not Foundend for

# # #3. Code (note,,. Do not paste on the blog. No need to use ... syntax to render)

4. Problems encountered in commissioning process and PTA submission List status note

In fact, I did not fight, I do not know where the error, the sense of thought are very ok, need torchbearer teacher to help me answer

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

Third, read the code (2 points)

The following code is required to input the teacher and classmate information, and then tidy up, if the input is the result of the input is the student, if the input of the subject is the teacher

#include <stdio.h> #include <stdlib.h> #define TOTAL 4//headcount Struct{ char name[20]; int num;  char Sex; char profession; union{  float Score;  char course[20]; } SC;} Bodys[total];int Main () { int i; //input personnel information  for (i=0; i<total; i++) {  printf ("Input info:") ;   scanf ("%s%d%c%c", Bodys[i].name, & (Bodys[i].num), & (Bodys[i].sex), & (Bodys[i].profession) );   if (bodys[i].profession = = ' s ') {//If it is a student    scanf ("%f", &bodys[i].sc.score);   }else{//If the teacher    scanf ("%s", Bodys[i].sc.course);   }  fflush (stdin);  } //Output Personnel information  printf ("\nname\t\tnum\tsex\tprofession\tscore/course\n");  for (i=0; i<TOTAL; i + +) {  if (bodys[i].profession = = ' s ') {//If student    printf ("%s\t%d\t%c\t%c\t\t%f\n", Bodys[i] . Name, Bodys[i].num, Bodys[i].sex, Bodys[i].profession, bodys[i].sc.score);   }else{//If it is teacher    printf ("%s\t%d\t%c\t%c\t\t%s\n", Bodys[i].name, Bodys[i].num, Bodys[i].sex, Bodys[i]. profession, bodys[i].sc.course);   } } return 0;}

The advantage of this is that a community is used in the structure, which not only saves memory, but also uses ingenious

Iv. Summary of the study this week (1 points) 1. Summarize what you learned this week.

Study this week, the structure of the body
1: Concept of the structure, definition. Structure is a new type of data construction, he can aggregate different types of data into a whole, so that they relate to each other;
2: There is also the use of struct arrays and struct pointers,
3: Another impressive is recursion, to tell the truth recursion is a bit difficult to understand, will always be around. Well, you need to take a look.

2. List some of the wrong questions this week.

Program Fill in questions:
Enter N (3<n<=10) employee's number, name, basic salary, dominate, the output of which "basic salary + dominate" the minimum and maximum number of staff names.
Input Output Sample:
N=5
1, Y.S., 1800,600
2, Li Tao, 1700,550
3, Wang Gang, 2100,750
4, Zhou Ai, 1500,450
5, Jinming, 2300,850
Base salary + dominate minimum: Weekly
Base salary + dominate the most is: jinming
This question my answer to the struct worker S[n] &num,name,&jbpay,&zwpay;
Max=i; Min=i; The standard answer is a struct Worker s[10]
&s[i].num,s[i].name,&s[i].jbpay,&s[i]zwpay
Max=i
Min=i error again with input structure array does not need to use the address character

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.