11th Time Assignment

Source: Internet
Author: User

First, the contents of the experiment

1. Experimental requirements

Enter a string that counts the number of uppercase and lowercase letters, spaces, numbers, and other characters. (Requires a character array

Code

#include <stdio.h>#include<conio.h>#defineN 100intMain () {CharCstr[n]; intI,d=0, x=0, s=0, n=0, o=0; printf ("Please enter a string \ n");    Gets (CStr);  for(i=0; cstr[i]!=' /'; i++)    {        if(cstr[i]<='Z'&&cstr[i]>='a') {x++; }        Else if(cstr[i]>='A'&&cstr[i]<='Z') {D++; }        Else if(cstr[i]==' ') {s++; }        Else if(cstr[i]<='9'&&cstr[i]>='0') {n++; }        Else{o++; }} printf ("uppercase has%d \ n lowercase letters%d \ n spaces have%d \ n number %d \ n Other%d", D,x,s,n,o); return 0;}

Program Run Results

2. Experimental requirements

Use a character array for password verification, if the password is correct, the login succeeds, otherwise the login fails. The password allows you to enter three times.

Code

#include <stdio.h>#include<string.h>intMain () {inti; Charpassword[]="Secret", input[8];  for(i=0;i<3; i++) {printf ("Please enter the password \ n"); scanf ("%7s", input); if(strcmp (password,input) = =0) {printf ("Welcome");  Break; }        Else{printf ("input error \ n"); }    }    return 0;}

Program Run Results

3. Experimental requirements

Write a function that determines whether a string is a palindrome. If the Palindrome function returns a value of 1, otherwise the return value is 0. A palindrome is the same as reading and falling. such as "Level" "ABBA" and so on is a palindrome, but "ABCD" is not a palindrome. A palindrome function is called in the main function to judge the input string.

Code

#include <stdio.h>#include<conio.h>#include<string.h>#defineN 100intHuiwen (Charcstr[]);intMain () {CharCstr[n]; printf ("Enter a string");    Gets (CStr); if(Huiwen (cstr) = =1) {printf ("It's a palindrome number ."); }    Else if(Huiwen (cstr) = =0) {printf ("not a palindrome number ."); }    return 0;}intHuiwen (Charcstr[]) {    inti,j; J=strlen (CStr)-1;  for(i=0;i< (j/2.0)-1; i++)    {        if(cstr[i]==cstr[j-1-i]) {Continue; }        Else        {            return 0; }    }    return 1;}

Program Run Results

Second, the experimental summary

1. To limit the number of strings

2. In experiment 3, the types of variables that need to be aware of functions defined in the function

3. Character numbers must be limited to the array length string cannot contain spaces

Third, the curriculum experience

1. After one semester of study, have you counted how many lines of code have been written? What do you know about C language or program design compared to the beginning of school?

After a semester of study I did not count how much code I wrote, because it feels like writing code is a very painful thing, the sense of accomplishment is far more than the feeling of fear. At the beginning of the school I do not know the C language, the first class after the very big, it is very difficult to adapt to the first contact with a strange C language is really scary, but after a semester of study, in the teacher's carefully under the C language learning has a certain confidence, C language is no longer difficult to resist, It's a big step for me to try.

2. What experiences and lessons do you share in the C language learning process?

I have no valuable experience in C language learning, but there are many lessons. For example, reading textbooks, writing code must read the textbook, not with a lot of just the doubts to write code, and then there is practice, for a program has to write out ideas. Note In the program is also important, if the idea is interrupted, comments can provide a good help.

3. What do you think of the form of submitting a job with a technical blog, and where is it helpful? What improvements do you think you can make? , would you recommend this type of teaching if your next school brother and sister are enrolled?

I think the technical blog submitted homework form is very good, not only can urge us to study, but also can increase our opportunity to communicate with the teacher. This is a very appropriate form of teaching.

4. For this course, for the work of teachers and teaching assistants, you have any good suggestions or comments, can be proposed, we improve together.

5. Please organize your own blog, starting from the first homework (including your self-introduction Oh, not write the students, welcome to fill up), all the blog content including comments saved to the Word document, and then sent to my mailbox. I will make up a blog book, stay as a course material, also will share for everyone to stay as a souvenir.

11th Time Assignment

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.