First, the PTA Laboratory work Topic 1:7-3 Year of birth 1. PTA Submission List
2. Design Ideas
定义y放年份,n放不同数字个数输入y和n的值for(i=0;i<4;i++)a[i]=b%10; 把年份各个位数的数字赋值给数组ab/=10;for(i=0;i<4;i++){ for(j=i+1;j<4;j++)遍历数组a,如果数字一样count减一,且跳出内循环如果count值等于n满足题意停止循环,输出年份和相差的年份如果不满足年份加一,其他重新赋值继续循环到满足题意,输出
3. Code
4. Problems encountered in commissioning process and PTA submission List status note
There is a problem with the format of the start output without leading zeros. In the output section of the format of the modification is possible.
Topic 2:7-5 Array Looping left 1. PTA Submission List
2. Design Ideas
定义n,m放左移次数,t,j输入n,m的值输入数组的值if(m>n) m=m-n遍历数组if(i>=m) for(j=i;j>i-m;j--){ 数字两两交换移动 t=a[j-1]; 到满足题意的移动位置 a[j-1]=a[j]; a[j]=t; for(i=0;i<n;i++){ if(i==n-1) 是数组最后的数后面不加空格,直接输出数字 else 输出对应数组数字加空格
3. Code
4. Problems encountered in commissioning process and PTA submission List status note
After submission are all format errors, read the topic carefully to find the format requirements. The output plus the judging conditions can be
There is also a test point m>n answer error, a special analysis of the situation, the assignment will meet the test instructions
Topic 3:7-7 Find Saddle point 1. PTA Submission List
2. Design Ideas
定义n,i,j,k,max放行的最大值,c记录行标,b记录列标输入n的值,给数组赋值 for(j=0;j<n;j++) max赋值为每行第一个数 for(i=0;i<n;i++) if(a[j][i]>=max){ //找出行中的最大值// max=a[j][i];c=j;b=i记录下下标for(k=0;k<n;k++) 判断最大值对应的列该值是否为最小值是:输出下标不是:输出NONE
3. Code
4. Problems encountered in commissioning process and PTA submission List status note
One error is the answer error is found to be the case of the output does not match the title
When there are two side-by-side saddle-point outputs: The maximum value to start in the row is compared with the preceding one. Add an equal sign: A[j][i]>=max takes the back one.
Second, this week's topic set PTA Final ranking.
Third, peer-to-peer evaluation of code pairs
My Code:
Wenjie Code:
Evaluation: His code to take the number of digits of the method is somewhat complex and only for special cases, my more concise and meet the general situation
He judged the different numbers to be finely divided in each case, which was very clear but too long. I used the loop to judge relatively simple, slightly some thinking
The problem is similar in practice, the difference is that the choice of code format is different.
Iv. Study Summary of the Week 1. What did you learn? How do I store strings in 1.1 C?
c中定义字符型数组存储字符串
1.2 What is the end flag of a string and why do you want to end the flag?
结束标志:\0原因:如果没有\0,就不知道字符串在哪结束,导致错误。
1.3 What are the methods for string input?
- 1.使用循环结构和scanf("%c", )语句输入 - 2.scanf("%s", )遇到空格就会中止 - 3.gets()这种方法只有遇回车会终止 - 4.getchar()输入单个字符
1.4 Numeric characters How to turn an integer, write a pseudo-code?
定义字符ch存放数字字符输出ch-‘0‘
1.5 16 binary, binary string how do I turn 10 binary? Write pseudo-code?
####16进制: 定义字符数组a[100]放16进制字符串,result放转化后的结果 输入数组的值 for 第一位to最后一位 若a[]为字符0到9,result=result*16+a[k]-‘0‘; 若a[]为a到f或A到F,result=result*16+a[k]-‘a‘或‘A‘+10; 输出结果####2进制 定义字符数组a[100]存储16进制字符串,result放转化后的结果 输入数组得值 for 第一位to最后一位 若a[]为字符0或1,result=result*2+a[k]-‘0‘; 输出结果
2. This week's content, you are not what?
- Preview work of some of the topics are to get the dev-c run to get the answer, your own analysis will often go wrong.
The judgment of the cyclic condition also often comes up with some mistakes, and has found a way of thinking but wrong in this step.
3. Midterm summary 3. Midterm summary
Basic knowledge is not well-grounded
The code is not well written.
3.3 The second half semester how to adjust C's study?
Preview more carefully, the foundation to play a bit more solid
The problem of PTA more to practice
Take a look at someone else's code and improve your code reading and writing skills.
C Language Blog Job--one or two-dimensional array