C Language Blog Job--character array

Source: Internet
Author: User

One, PTA laboratory work (4 points) Title 1:7-1 string converted to decimal integer 1. PTA Submission List (to submit list, not result)

2. Design ideas (pseudo-code or flowchart)
    • The i,j,k is defined as a cyclic variable, and flag is used to determine if the input symbol is negative, f to determine if the input character is a hexadecimal character, and then ten to store the decimal number, array a[80],str[80]; Store string
      flag=1,f=1;
      Input string A[i]
      k=0;
      for (i=0;a[i]!= ' n '; i++) {
      If A[i] belongs to the characters ' 0 ' to ' 9 ' or ' a ' to ' Z ' or ' a ' to ' Z '
      str[k++]=a[i];f=0;
      If f=1&&a[i]== '-' flag=0;}
      ten=0;
      for (k=0;str[k]!= ' n '; k++) {
      Convert hexadecimal characters to decimal digits}
      if (flag==0&&ten==0) printf ("0");//When input-0 should output 0
      if (flag==1)
      printf ("%ld\n", ten);//no minus sign in input characters
      if (flag==0&&ten!=0) printf ("-%ld", ten)//a minus sign in the input character
3. Code (note,,,. Do not paste on the blog. No need to use ... syntax to render)

4. Problems encountered in debugging process and PTA Submission List situation description.
    • 1. The title requires that if the character "-" exists before the first hexadecimal character, the number is negative. Indicates that only the symbol before the first hexadecimal number is counted, not in the middle, but my program does not know why it cannot output a negative value.
    • Solution: I later with DEVC debug run found, do not know why run to judge A[i] is not '-' This sentence when the program directly out of the loop, and then directly run to the outside of the loop to determine the output conditions that sentence, so Judge a[i]= '-' again make flag= 0 as the output condition this sentence will not be executed, nor can output negative values.

Finally I do not know exactly which sentence is a problem, so a little change of thinking to change the program, I used to use the statement if (a[i]>= ' 0 ' &&a[i]<= ' 9 ' | | A[i]>= ' a ' &&a[i]<= ' F ' | | a[i]>= ' A ' &&a[i]<= ' F ' | | a[i]== '-' | | a[i]== ' + ') to determine whether a character is a hexadecimal character, and later I changed to if (a[i]>= ' 0 ' &&a[i]<= ' 9 ' | | A[i]>= ' a ' &&a[i]<= ' F ' | | a[i]>= ' A ' &&a[i]<= ' F ') then in the phrase if (a[i]== '-') flag=0; To determine if the input character is a minus sign.

    • 2. The title requires that the minus sign is not counted in the middle, but my program still counts him in.
    • WORKAROUND: The Judgment statement if (a[i]== '-') flag=0; change to if (a[i]== '-' &&f=1) flag=0; indicates that the minus sign enters the hexadecimal character before entering the loop.
Topic 2:7-3 Find the longest string 1. PTA Submission List (to submit list, not result)

2. Design ideas (pseudo-code or flowchart)
    • Define I,J, which is the loop variable, count is used to determine the longest string, n is the number of strings to be judged, a[80], the string is stored, str[80], and the longest string is stored.
3. Code (note,,,. Do not paste on the blog. No need to use ... Syntax to render) 4. The debugging process encountered problems and PTA submission List of the status note. Topic 3:1. The PTA submission List (to submit the list, not the result) 2. Design ideas (pseudo-code or flowchart) 3. Code (note,,. Do not paste on the blog. No need to use ... Syntax to render) 4. The debugging process encountered problems and PTA submission List of the status note. Second, this week's topic set PTA Final ranking. Third, peer code peer review (1 points) 1. Peer Name 2. My Code, mutual evaluation of the student code (here The core code is good, not all the code, the figure indicates whose code.) 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. Iv. Summary of the study this week (3 points) 1. What have you learned? 1.1 How pointer variables are defined (design code can be rendered with markdown code symbols)?
    • Type name pointer variable name such as int p.

      1.2 pointer addition operation in which case, can the 2 pointer variables be added to each other?
    • 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? 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. 1.6 How to define a pointer variable to an array, and how to use a pointer variable to represent an array element? 1.7 How do I define a character pointer to a string? Where is the initial position after the pointer points to the string? 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? 2. What is your content this week? 2.1 Class allocation and how to revise the wrong questions. 2.2 Others not? What are you going to do? 3. Array on-Machine exam summary 3.1 The wrong question, please list? 3.2 Wrong question How to revise, why wrong?

C Language Blog Job--character array

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.