11th Time Assignment

Source: Internet
Author: User

First, the contents of the experiment

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

#include <stdio.h>#defineN 100intMain () {CharZifu[n]; intA=0, b=0, c=0, d=0, e=0, I; printf ("Please enter a string \ n");    Gets (Zifu);  for(i=0; zifu[i]!=' /'; i++)       {         if('A'<=zifu[i]&&zifu[i]<='Z') A++; Else if('a'<=zifu[i]&&zifu[i]<='Z') b++; Else if('0'<=zifu[i]&&zifu[i]<='9') C++; Else if(zifu[i]==' ') d++; Elsee++; } printf ("Capital Letter%d, lowercase%d, number%d, space%d, other characters%d \ n", a,b,c,d,e); return 0;} 

2. 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.

#include <stdio.h>#include<string.h>intMain () {Charpassword[]="000000", input[8]; inti;  for(i=0;i<3; i++) {printf ("Please enter the password \ n");        Gets (input); if(strcmp (password,input) = =0) {printf ("Enter right!");  Break; }        Else{printf ("input Error!\n"); }        if(i==2) printf ("Login Failed"); }           return 0;}

3. 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.

#include <stdio.h>#include<string.h>intHuiwen (Charc[]);intMain () {Charstr[]={' /'}; printf ("Please enter a string: \ n"); scanf ("%s", str); if(Huiwen (str) = =1) {printf ("It's a palindrome number \ n"); }    Else if(Huiwen (str) = =0) {printf ("not a palindrome number \ n"); }    return 0;}intHuiwen (Charc[]) {    intI=0, j=0;  for(i=1, J=strlen (c); i<=j;i++,j--)    {        if(c[i]==C[j])return 1; }    return 0;}

(ii) Experimental summary

1. The ' \ "flag string ends, but it is not part of the string.

2. When an array is initialized with an initial value of less than the number of elements in the array, the system automatically adds '/s ' to the subsequent element.

The 3.gets function can enter a string with spaces.

The 4.SCANF function cannot enter a string with spaces.

(iii) Lessons learned

1. After a semester of study, I do not have specific statistics on how many lines of code, but should not be very little, with the depth of study, let me feel the difficulty of C language, there are some difficulties and obstacles, found to learn C language is not so easy to imagine.

2. Learn C language, the class to listen to understand the key is not left behind, before oneself often in class absent-minded to concentrate on lectures, the class of their own review found more difficult, the key points of knowledge have not heard, in the writing process also encountered one after another problem.

3. Blog Submission of homework I think is a very good form, so that we can skillfully master the method of online learning, and have a fixed time to hand in the work, but also can play a good role in urging everyone, if the study of younger sisters come I recommend this way.

4. Both the teacher and the teaching assistants are very good, and when they ask questions, everyone answers together.

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.