One, the PTA experiment homework problem one. Find the longest string 1. PTA Submission List
2. Design Ideas
- (1) Define n as the number of strings to be entered below, define I as a loop control variable to traverse each string, and define the input string as the largest array of op-retained strings,
Defines the maximum number of characters for a string of Max and assigns an initial value of 0, defines the variable s to traverse the OP to the most, and defines the input of the variable J for each string.
- (2) Input n
- (3) for (i=0;i<n;i++) {let J equals 0;
- (4) Enter each string with GetChar and record the number of characters with J
- (4) If max<j, let max=j; and the OP at this time will assign op to the most end
- (5) Output The longest is:%s\n,most
3. Code
4. Problems encountered in debugging process and PTA Submission List situation description.
Two times the wrong answer seems to be a parenthesis without an alignment missing a parenthesis.
Topic Two. Jack Cheng's Troubles 21. PTA Submission List
2. Design Ideas
The design idea of this problem is to divide the brackets into pieces of each one to judge.
4. Problems encountered in debugging process and PTA Submission List situation description.
I didn't understand it at first. The correct use of brackets is that (()) () This type of two blocks above is the wrong way to use is also very distressed why they have been submitting errors, and later asked the teacher found errors.
Topic three. Archaic typesetting 1. PTA Submission List
2. Design Ideas
3. Code
4. Problems encountered in debugging process and PTA Submission List situation description.
The difficulty lies in examining, the idea is relatively simple.
Second, this week's topic set PTA Submission List and the final ranking. PTA Rankings
Third, peer code peer review 1. Peer evaluation of the names of students
Zhong Wenjie
2. My Code, mutual evaluation of the student code
He
I
3. Where do I differ from my classmates ' code? What are the advantages? What style of code do you prefer? If the classmate code is wrong, please help to point out where the problem.
He called the library function inside the original existing function, I did not, his more simple and convenient, but need to remember, I am more complex. I prefer his concise style.
Iv. Study Summary of the Week 1. What did you learn? 1.1 How pointer variables are defined (design code can be rendered with markdown code symbols)?
int a; int *i=&a;
1.2 pointer addition operation in which case, can the 2 pointer variables be added to each other?
Using the pointer plus a constant, two pointers cannot be added as the hotel number 503 plus 607 is meaningless.
1.3 The pointer does not assign the initial value, direct use, what happens, please use DEVC verification, and show?
Program crashes
1.4 Lessons about separating the integer and fractional parts of a floating-point number, use DEVC to verify the implementation, and show it in this map, and also indicate which is the pointer variable to do the function parameter, and how the function argument should be represented. What is the use of pointer variables for function parameters? ‘
Pointer variables do function parameters:
How the function arguments should be represented:
It is possible to manipulate variables of the main function to implement multiple worthwhile returns.
1.5 Please change the bubble sort function of the textbook into a pointer variable to do the formal parameter format, and write the code at the bottom, pay attention to the markdown syntax rendering
void bubble(int *a,int n){ int i,j,t; for(i=0;i<n-1;i++){ for(j=0;j<n-i-1;j++){ if(*(a+j)>*(a+j+1)){ t=*(a+j); *(a+j)=*(a+j+1); *(a+j+1)=t; } }
1.6 How to define a pointer variable to an array, and how to use a pointer variable to represent an array element?
Let the pointer point to the first address of the array, which is the array name or element of the array.
(1) Manipulate the pointer as an array
(2) Add the pointer to the number I so that the pointer iterates through the array each element address.
1.7 How do I define a character pointer to a string? Where is the initial position after the pointer points to the string?
在c语言中定义一个指针 char *p;char str[10] = "afjkfdhsjk";p = str;
Pointer p points to the first address of the string str
1.8 Use a character pointer to manipulate strings, such as design functions, to implement string joins, and show the code in this map. What are the advantages of the method that indicates the pointer represents a character?
#include<stdio.h>#include<string.h>void connect(char*op,char*cpunt);int main(){ int k=0,i=0,j=0; char op[20]; char count[20]; gets(op); gets(count); connect(op,count); printf("%s",op); return 0;}void connect(char*op,char*count) { strcat(op,count); }
Can point to an address that does not need to allocate memory, the communication protocol used more than the general point of message content.
2. This week's content, you are not what? 2.1 Class allocation and how to revise the wrong questions.
Pointer and array second question empty, should be filled out is the address is not the number so to write is P+n
Select the seventh item in the pointer job selection C, *p is the value is not the address.
2.2 Others not? How are we going to solve
The pointer thought is not skillful, does many questions, solves more.
3. Array on-Machine exam summary 3.1 The wrong question, please list?
The problem is not wrong is the matrix which problem with the choice of sorting method to do relatively low
3.2 Wrong question How to revise, why wrong?
No
C Language Blog Job--character array