C Language Blog Job--character array

Source: Internet
Author: User

I. PTA LAB Assignment 1:7-1 string converted to decimal integer 1. PTA Submission List

2. Design Ideas

3. Code

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


    • I looked at the problem for a long time, tried a lot of wrong points, the answer is the same as I expected, so I re-read the topic, found that distorted the test instructions
      The first hexadecimal character before the existence of the character "-" is understood as the first hexadecimal character before the existence of the character "-"
Topic 2:7-7 Delete substring 1 in a string. PTA Submission List

2. Design Ideas
* 定义 i,j,k用于循环,count用于计数,s用于求子串的长度,s1=1,n=0;      //i,j,k用于循环   定义The_main_string[81];并且为0  定义substring[81];并且为0* 输入主串和子串用gets(),并且s=strlen(substring);* for循环,进入下一步  s1等于n;* for循环从i=0,直至主串为0,结束后i自增,进入下一步   count=0* for循环j等于i,k等于0;直至主串不等于子串;结束后j自增,k自增  count自增* 如果count等于子串长度s,那么对应主串的j-s+1个为0,且将主串j+1剪切过去,并且n++  end  end* 如果s1等于n,退出循环* 输出主串
3. Code

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


In this case, I will directly output a few values, on the paper to re-simulate the process of running the program, found that some of the algorithms are unreasonable, improved a bit

Topic 3:7-20 Specifies the position of the output string 1. PTA Submission List

2. Design Ideas
* 定义ij由于循环,n,数组d用于记录下标,字符数组a,字符形bc* 用gets输出a ,输出b,c* for i为0,直至a【i】为0进入下一步,i自增  如果a[i]等于b,d【j++】=i  如果a[i]等于c,n=i;end* 输出a[0]到n数组a的值
3. Code

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

The subject used a printf statement to see that encountered B and encountered C subscript, just at the beginning there is no n variable, and later found that when the 112211,1,2
So the input of the sub-bidding clubs transformation, so with N to record and only the last equal subscript

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

Third, peer code to peer evaluation of my Code

Jie Wei's code

    • I have the same idea as his, and the code is concise enough.
    • In the case of the overlay substring I am relying on the call library function of the cut, Jie Wei is the use of cyclic left shift, these two methods to see personal habits bar
Iv. Study Summary of the Week 1. What did you learn?
    • I learned the pointer, which also understand the memory before the problem, is a variable address, the location of the address can also be stored with pointers, pointers for the
      Address can also be known
    • I'll also learn to copy and cut with new library functions

1.1 How pointer variables are defined (design code can be rendered with markdown code symbols)?
~~~
int a,*p=&a;
~~~
1.2 pointer addition operation in which case, can the 2 pointer variables be added to each other?

    • Used to pointer to an array, and the pointer to increment represents the next
    • Pointer variables cannot be added, no meaning
      1.3 The pointer does not assign the initial value, direct use, what happens, please use DEVC verification, and show?

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 variable do function parameter void spllitfloat (float x,int* intpart,float* fracpart)
    • function argument spllitfloat (x,&realnumber,&decimalfraction);
    • You can change the value of the main function in the calling function
      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.
      ~~~

      Includevoid Bubble (int p,int n);
      int main ()
      {
      int a[100],n,i;
      scanf ("%d\n", &n);
      for (i=0;i<n;i++)
      scanf ("%d", &a[i]);
      Bubble (a,n);
      for (i=0;i<n;i++) {
      printf ("%d", a[i]);
      }
      return 0;
      }
      void Bubble (int
      p,int N)
      {
      int i,j,t;
      for (i=1;i<n;i++) {
      for (j=0;j
    • The initial position is the address at p
      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?
      ~~~

      Includeint Main ()
      {
      Char p1= "How is";
      Char
      p2= "You";
      printf ("%s%s", P1,P2);
      return 0;
      }
      ~~~
    • Can reduce the amount of code
    • Can reduce the amount of memory occupied
      2. What is your content this week?
    • I don't quite understand the use of char *p[]
    • I'm not very good with 0 of arrays.

2.1 Class allocation and how to revise the wrong questions.

    • For this problem, did not really understand the pointer to the array of the relationship, and understand the meaning of the topic, the teacher corrected, suddenly dawned.

    • This problem also did not understand the pointer and array relationship, after listening to the teacher after the lesson, only understand that the array name itself is an address, but can not change it

2.2 Others not? How are we going to solve
All the others understand.

3. The test summary of the array on the machine

    • The failure of this exam was to transpose the two-dimensional array in 6-2 jmu-c-and sort by column, where my algorithm was not wrong, but at the time I always thought
      My bubble sorting method error, on the paper simulation of the program's running process found no errors, and then kept looking, after a long time, only to see me in a[i]^=a[i+1]
      ^=a[i]^=a[i] This process i+1 forgotten.

3.1 The wrong question, please list?

3.2 Wrong question How to revise, why wrong?

~~~

Include

int main ()
{
int A;
scanf ("%d", &a);
printf ("%x\n", a);
return 0;
}
~~~

    • This problem is just beginning to design the idea is to create a character array to hold 16 binary 1 to f/f, another character array to hold the results,
      Later because of the time is not enough, did not finish, back to the dorm suddenly remembered, you can directly use the above code to run.

C Language Blog Job--character array

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.