I. PTA Lab Assignment Topic 1:7-4 simplified Insertion Sort
PTA Submission List
Design ideas
int a[10], assigning an initial value of 0
int N,x,i,t
Enter the value of n
Input array A
Enter the value of X
A[n]=x the number that will be inserted in the last
For 0 to N-1
If this number a[n] is less than one of the numbers, exchange their values
Print sort Results
3. Code
4. Problems encountered in debugging process and PTA Submission List situation description.
This question is no big problem, as long as the idea has, it is good to do, just at the beginning I did not put this to insert the number into the array, so the implementation can not be exchanged many times, the back put it in the good to do
Topic 2:7-6 Reading Room
- PTA Submission List
Design ideas
int n
int I,J,BOOKNUM,FLAG[1001] Assigns the initial value to the 0,t[1001],time=0 meter borrowing time, Count=0,y puts the hour, X puts the minute
Char Ch,space
For 0 to N-1
Time=0
Count=0
while (constancy)
{
Enter ISBN, Key number, time
If ISBN is 0, end work jump out of loop
The IF key number is S,t[booknum-1]=y60+x;flag[booknum-1]=1,flag is 1, which is indicated as the borrowing status
Else
{if flag[booknum-1] is 1 flag[booknum-1]=0; flag is returned to 0 for return, ready for next input; count increment; Time=time+y60+x-t[booknum-1] calculates total time
}
If Count is 0 output 0,0
Else output borrowing count and average reading time
}
3. Code
4. Problems encountered in debugging process and PTA Submission List situation description.
Start do not know how to calculate the borrowing time, ask a classmate, is to set the starting point at 0, and then all the time into minutes to subtract is the time of borrowing
There is a depressed place, that is, the key value of the case, the beginning I hit the lowercase, find a half-day did not find, and then read carefully to see
Topic 3:7-9 Judging the upper triangular matrix
PTA Submission List
Design ideas
int T,n,i,j,k,a[11][11],flag=0flag To determine if it is the upper triangular matrix
Enter the value of T
for 1 to T
{
Flag=0, the flag is initialized to 0 per loop
Input matrix A
I for 0 to N-1
{J for 0 to I
If A[I][J] is not equal to 0,flag=1, jump out of the loop
}
If flag equals 0 output Yes
else Output No
}
3. Code
4. Problems encountered in debugging process and PTA Submission List situation description.
The main problem is that the flag is not changed to 0 at the beginning of each cycle, causing the loop to go wrong after debugging and finding that the flag value remains unchanged before it becomes aware of the problem.
Second, this week's topic set PTA Final ranking.
Third, peer-to-peer evaluation of code pairs
1. Mutual evaluation Students Name: Zhong Wenjie
2. My Code, mutual evaluation of the student code
My Code
Zhong Wenjie's Code
3. Where do I differ from my classmates ' code? What are the advantages? What style of code do you prefer?
First of all, his code is more concise than I, the overall design of the idea is similar, but I think more than he, think of the first number of judgment, and he did not, but he also has a concise place, such as I used a max to put up the maximum number of times, can actually not
Iv. Summary of this week's study
1. What have you learned?
How do I store strings in 1.1 C?
Use a character array to save
1.2 What is the end flag of a string and why do you want to end the flag?
To facilitate a given cycle condition
1.3 What are the methods for string input?
scanf ("%s", a);
Gets (a)
for (i=0;i<10;i++)
scanf ("%c", &a[i]);
while ((A[i]=getchar ())! = ' \ n ') i++;
1.4 Numeric characters How to turn an integer, write a pseudo-code?
char c;
int n;
Enter character number C
n = c-48
Output integer number
1.5 16 binary, binary string how do I turn 10 binary? Write pseudo-code?
Char hexad[80]
int number
Number=0
I for 0 to hexad[i] not equal to
{if hexad[i] is a digital number=number16+hexad[i]-48
else if Hexad[i] is an uppercase letter Number=number16+hexad[i]-65+10
else if hexad[i] is a lowercase letter number=number*16+hexad[i]-97+10
Char two[80]
I for 0 to two[i] not equal to
N=7
If n>=0
{
term= (two[i]-' 0 ') *pow (2,n);
Sum=sum+term;
}
N Self-reduction
2. This week's content, you are not what?
PTA on the identification of identity card that problem has a checkpoint do not know what meaning
and delete the substring in the string.
Attached code
3. Midterm summary
3.1 Why do you think you didn't do well?
The first written exam, a bit uncomfortable, there is a lot of things back not familiar with the code is not proficient in writing
3.2 List the wrong questions.
Examining not serious.
Missing an equal sign, the condition of the boundary point is not clear.
3. Correct the last one did not change the problem, n++ to n=n+2, usually n++ write habits, he slightly passed
How does the plural count not
Delta=bb-4aC; re=-(double) b/(2a);
IM=SQRT (Fabs (Delta))/(2*A); if (delta<0) {
printf ("There are two different complex roots X1=%.6lf+%.6lfi, X2=%.6lf-%.6lfi \ n", Re,im,re,im);
3.3 The second half semester how to adjust C's study?
Sharpening does not mistake chopping wood work, I think the knowledge thoroughly understand first, otherwise the topic does not have the efficiency
C Language Blog Job--one or two-dimensional array