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># define N -intMain () {intA=0, b=0, d=0, e=0, t=0, N; CharC[n]; Gets (c); for(n=0; c[n]!=' /'; n++) { if(c[n]>='A'&&c[n]<='Z') {a++; } Else if(c[n]>='a'&&c[n]<='Z') {b++; } Else if(c[n]>='0'&&c[n]<='9') {D++; } Else if(c[n]==' ') {e++; } Else{T++; }} printf ("There are%d in uppercase letters,%d in lowercase,%d for numbers,%d for spaces, and%d for other characters", a,b,d,e,t); 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># include<stdlib.h>intMain () {intNumber=3; Charpassword1[7],password2[7]; printf ("Please set the 6-digit password: \ n"); scanf ("%s", Password1); printf ("Please enter your password: \ n"); while(number!=0) {scanf ("%s", Password2); if(strcmp (password1,password2) = =0) {printf ("The password is correct \ n"); Break; } Else{ number=number-1; printf ("wrong password, and you have%d chances.", number); } } 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>intPutnum (Charnum[]);intMain () {Charnum[7]; printf ("enter a string of characters \ n"); scanf ("%s", num); if(Putnum (num) = =1) {printf ("It's a palindrome number \ n"); } Else{printf ("not a palindrome number \ n"); } return 0; } intPutnum (Charnum[]) { intA,i,j,c; C=strlen (NUM)-1; for(j=c,i=0; i<=j;i++,j--) { if(num[i]!=Num[j]) { return 0; }}return 1;}
Second, the experimental summary
1. When outputting a string with the "%s" format, printf outputs a character array name instead of an array element name.
2. The string ends with a, not \ n.
3, the third question for the statement condition if there are more than one expression can be used, separate.
4. If an array contains more than one ' + ', the output ends when you encounter the first '
5. Use the "%s" format character to output a string without adding an address character
Third, the curriculum experience
1, after a semester of study, you have counted how many lines of code written? What do you know about C language or program design compared to the beginning of school?
Wrote about 1700 lines around, just at the beginning completely do not know this is God ghosts, with the subsequent study found C language good magic, writing programs
2. What experiences and lessons do you share in the C language learning process?
Be sure to preview, write more programs, read more about how others write, especially those who learn well
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?
Blog Park in hand homework to me very helpful, more convenient, can through the comments of others on my program to find their own shortcomings, but also can see other people's procedures on their own have no inspiration, see other people out of the wrong whether they will also commit.
Would recommend it, but if I had a brother and sister who wouldn't recommend learning this
11th Time Assignment