C Language Blog Job-data type

Source: Internet
Author: User
Tags array length

First, the PTA laboratory Work Topic 1. The number that falls into the trap 1. PTA Submission List

2. Design Ideas

1. Define Shaping variables N,result,i
2. Input data n
3. Enter the loop with no end condition
4. Assign the value returned by the function to result
5. Output I and result by format
6. Judging if n==result, jump out of the loop
7. Assign the value of result to N and start the next loop
8. In the function, define the sum=0
9. Take n numbers, add
10. Return to Sum*3+1

3. Code

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

Just start choosing to put all the code together and then find the wrong pile, and then write it again. With the function of the words of clarity, once on the past.

Topic 2. Judging the legal identifier 1. PTA Submission List

2. Design Ideas

1. Define shaping variable Repeat,flag, character variable op
2. Enter the number of cycles repeat
3. Enter the loop when repeat is true
4. Input character op
5. When the first character enters a judgment statement at a-z,a-z or _
6.flag=1 represents a valid variable
7. Enter the loop when OP is not read into the carriage return
8. If it is a valid character, continue the loop, otherwise let flag=0
9. If flag==1, output yes, otherwise output no
10. Step 5th, if you do not enter a judgment statement, direct output No

3. Code

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

The run timeout was found before the time of submission and cannot be ended

Later found not to let repeat play a role, so let repeat--to solve

Topic 3. Simple Calculator 1. PTA Submission List

2. Design Ideas

1. Define X,y,res, character variable op
2. Enter the first operand x and let x assign to Res
3. Input character representation operator
4. If OP does not get =, enter the loop
5. Enter Operand y
6. If the denominator is 0 or an illegal operator, the error is output and the memory is emptied directly
7. If op gets +, let X+y assign to Res
8. If op gets----gives the X-y value to Res
9. If op gets/, let X/y assign to Res
10. If op gets , let xy assign to Res
11. Assign the res to X, enter the next operator, and make the next loop
12. Output Res

3. Code

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

When the PTA is submitted, there is always a score point did not get is that the smallest expression, and later found that if an operand, there is no operator, has been = 0 only need to add a res=x before entering the cycle of the line

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

Iii. Summary of this week's study 1. What did you learn? 1.1 How is a one-dimensional array defined and initialized?

Definition: Array type array name [array length]; Array length is a constant
Initialize: Type an array group name [array length]={initial value table}, such as Inta a[10]={1,2,3,4,5,6,7,8,9,10}; Special, statically stored array if not initialized, the system automatically assigns 0 to all array elements

1.2 A one-dimensional array in-memory structure? can draw a description. What does an array name mean?

A linear structure in which the array name represents a variable, and the first address of the array is used alone.

1.3 Why use arrays?

Simple and tidy, can be recycled, you can store all the arrays.

1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo code display.
选择法:1.int a[n];//先给数组赋值,数组长度为n2.for(k=0;k<n-1;k++) index=k;最小值下标为k循环第三步3.for(i=k++;i<n;i++)循环第四步4.如果a[i]小于最小值,则最小值与下标为k的值交换5.输出数组冒泡法:两两比较待排序的数,发现两个次序相反即进行交换,直到没有反序为止。1.定义变量int a[10],i,j,k2.for(i=0;i<10;i++) 依次输入数据存入数组3.for(i=0;i<9;i++) 循环第四步4.for(j=0;j<10-i;j++)循环5.if(a[j]>a[j+1]) 则交换这两个数即k=a[j];a[j]=a[j+1];a[j+1]=k;6.for(i=0;i<10;i++) 依次输出a[10]中每个数直接插入法:1.先给数组赋值,n为数组长度2.for(k=0;k<n-1;k++) index=k;最小值下标为k循环第三步3.for(i=k++;i<n;i++)循环第四步4.如果a[i]小于最小值,则最小值与下标为k的值交换5.输出数组
1.5 What is the binary search method? It differs from the order lookup method?
二分法:1.确定该区间的中点位置2.将待查的K值与a[mid]比较3.若相等,则查找成功4.若a[mid]>K,则新的查找区间是a[1-(mid-1)]5.若a[mid]<K,则新的查找区间是a[(mid+1)-n]顺序查找:从表的一端开始,顺序扫描线性表,依次将扫描到的结点关键宇和给定值K相比较。若当前扫描到的结点关键字与K相等,则查找成功;若扫描结束后,仍未找到关键字等于K的结点,则查找失败。区别:当查找数列是有序的话,使用二分查找法可以极大的减少搜索时间,提高效率;顺序查找法可以查找无规律的数列,但是需要耗费大量的时间和内存逐个搜索关键词。
1.6 How are two-dimensional arrays defined and initialized?

Definition of a two-dimensional array: Type an array group name [length of line] [column];
Initialize: Type an array group name [line length] [column lengths]={{initial value table 0},...,{initial value table K}, ...} ;
The initialization of a two-dimensional array can also be specific to some elements;
The order assigns the initial value: according to the order of the array element in memory, assigns the data in the initial value table to the element sequentially, if only assigns the initial value to the partial element, must pay attention to the initial value table the data writing order;
When a two-dimensional array is initialized, if all the elements are assigned an initial value, or if the branch is assigned an initial value, all rows are listed in the initial value table, and the row length can be omitted

1.7 How is the matrix transpose implemented? In the matrix: the relationship between the row label I of the lower triangle, the upper triangle and the symmetric matrix J? Please state.
矩阵转置:定义数组a[i][j],那么数组b[j][i]就是数组a[i][j]的转置矩阵;下三角:i>=j上三角:i<=j对称矩阵:i=j
1.8 What is the general application of a two-dimensional array?

Two-dimensional tables and matrices

2. This week's content, you don't have anything

The understanding of the two-dimensional number is not very thorough, and the definition of the array has a number of forms a little understanding, to learn more

C Language Blog Job-data type

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.