C Language Blog Job--character array

Source: Internet
Author: User
Tags array length

First, the PTA laboratory work Title 1:7-2 count the number of words in a line of text 1. PTA Submission List

2. Design Ideas
     定义字符数组ch[1000],定义i用于循环,count用来数有几个单词,count1记录字符串有多长     输入字符串,并将字符串存储在字符数组中     如果ch[0]是空格,count=0     否则count=1     for i=0 to count1        如果ch[i]是空格或逗号,并且它们的下一个字符是字母或数字        count++     end for     输出count的值
3. Code

4. Problems encountered in commissioning process and PTA submission List status note


At first, these test points are not enough, the first test point is correct, the following two test points after the array length has been changed, but the first Test point has become an answer error, and do not understand exactly where the wrong, and do not know which direction to debug

Topic 2:7-5 Statistics uppercase consonant letter 1. PTA Submission List

2. Design Ideas

3. Code

4. Problems encountered in commissioning process and PTA submission List status note

At first, when judging the condition is ch[i]!= ' A ' &&ch[i]!= ' E ' &&ch[i]!= ' i ' &&ch[i]!= ' O ' &&ch[i]!= ' U ', Count adds a , in such a judgment condition, if there is a space, then count will also add one, and the space is not consonant, should be disregarded

Topic 3:7-10 positive integers a+b1. PTA Submission List

2. Design Ideas
    定义两个字符数组c1[80],c2[80],定义i,j用于循环,flag1和flag2做是否为正整数的标记,num1为第一个正整数,num2为第二个正整数    当getchar()!=‘\n‘时,    c1[i]=getchar;i++    end getchar    c1[i]=‘\0‘    gets(c2)   for i=0 to c1[i]!=‘\0‘     如果不是数字          flag1=1     否则          将该数字字符转成数字     end for     如果num1的值不在1-1000内,     flag1=0     对字符数组c2[80]做同样的操作     根据不同的flag1和flag2的值,输出相应的结果
3. Code


4. Problems encountered in commissioning process and PTA submission List status note

Ignore when the value is not within the scope of the problem, such as num1=0,num2=1001, the output should be a question mark, and my Code output is 1001, plus judge whether the number in the scope of the requirements of the conditions after the passage of

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

Third, peer code peer review 1. Peer evaluation of the names of students

Shen Mengting

2. My code, peer-to-peer code (the core code here is good, not necessarily all the code, the figure indicates whose code.) )

Classmate's Code

   #include<stdio.h>int main(){    char a[1000];    int i,count=0,flag=0;    gets(a);    for(i=0;(a[i])!=‘\0‘;i++)    if(a[i]==‘ ‘) flag=0;    else if(flag==0){    flag=1;    count++;    }    printf("%d",count);    

My Code

   #include<stdio.h>int main(){    char ch[1000];    int i,count,count1;    while((ch[i]=getchar())!=‘\n‘)    i++;    ch[i]=‘\0‘;    count1=i;    if(ch[0]==‘ ‘)    count=0;    else     count=1;    for(i=0;i<=count1;i++){    if((ch[i]==‘ ‘||ch[i]==‘,‘)&&(ch[i+1]>=‘a‘&&ch[i+1]<=‘z‘||ch[i+1]>=‘0‘&&ch[i+1]<=‘9‘))     count++;}    printf("%d",count);    return 0; }
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. 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,*p;   p=&a;

Or

    int a;    int *p=&a;
1.2 pointer addition operation in which case, can the 2 pointer variables be added to each other?

Pointers can be added to integral types of data
No, the addition of 2 pointer variables is illegal

1.3 The pointer does not assign the initial value, direct use, what happens, please use DEVC verification, and show?

program does not function properly

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?
   int a[8];   int *p;   p=a;

*p

1.7 How do I define a character pointer to a string? Where is the initial position after the pointer points to the string?
   char *s="point";

Initial position in the first character of 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?

Benefit: Operate directly on the elements within the address

2. What is your content this week? 2.1 Class allocation and how to revise the wrong questions.


The second empty should be p+n, at that time in the reference book similar content, directly to the book 9 written up

2.2 Others not? How are we going to solve

PTA on the topic of the character array, some of their own look at the time a bit of thinking, but do not know how to write, some are completely no idea how to write, need to ask students to write.
ID card that question, just start do not understand the weighted sum is what mean, ask the classmate after only know.
For not yet the topic, I would like to try to write their own first, if still will not be on the Internet to check or to ask classmates.

3. Array on-Machine exam summary 3.1 The wrong question, please list?

jmu-c-two-dimensional array transpose and sort by column
IP Address Translation
jmu-c-decimal Turn 16 binary

3.2 Wrong question How to revise, why wrong?

1.jmu-c-two-dimensional array transpose and sort by column

    1. IP Address Translation
      Correction

      Binary conversion to decimal method error
      3.jmu-c-decimal Turn 16 binary

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.