Third time job

Source: Internet
Author: User

1.


#include <stdio.h>intMain () {CharA; printf ("Please enter a character"); scanf ("%c",&a); if(a>='A'&&a<='Z') {a=a+ +; printf ("%c", a); } Else if(a>='a'&&a<='Z') {a=a- +; printf ("%c", a); } Else if(a>='0'&&a<='9') {printf ("%c", a); } Else if(a==' ') {printf ("Space"); } Else{printf (" Other"); } return 0;}

2.

#include <stdio.h>intMain () {inta,b,c,d,e,f,g; printf ("Please enter your birthday."); scanf ("%d,%d,%d",&a,&b,&c); printf ("Please enter today's date"); scanf ("%d,%d,%d",&d,&e,&f); if(b>e) {g=d-a-1; }    Else if(b=e) {if(c>f) {g=d-a-1; }        Else{g=d-A; }    }    Else{g=d-A; } printf ("real age is%d", G); return 0;}

3.

#include <stdio.h>intMain () {intA,b,c; printf ("Please enter three sides of the triangle"); scanf ("%d,%d,%d",&a,&b,&c); if(a+b>c&&a+c>b&&b+c>a&&a-c<b&&a-b<c&&b-c<a) {if((a==b&&a!=c) | | (a==c&&a!=b) | | b==c&&b!=a) {printf ("isosceles Triangle"); }        Else if(a==b&&b==c) {printf ("equilateral triangle"); }        Else if((a*a+b*b==c*c) | | (b*b+c*c==a*a) | | a*a+c*c==b*b) {printf ("Right Triangle"); }        Else if((a==b&&a*a+b*b==c*c) | | (a==c&&a*a+c*c==b*b) | | b==c&&b*b+c*c==a*a) {printf ("isosceles Right Triangle"); }        Else{printf ("General Triangles"); }    }    Else{printf ("Non-triangular"); }    return 0;}

4.

#include <stdio.h>#include<stdlib.h>#include<time.h>intMain () {intb; printf ("Please enter the price"); scanf ("%d",&a); Srand (Time (NULL)); b=rand ()% -+1; if(a> -|| a<0) {printf ("Please re-enter"); } Else if(a<b) {printf ("guess it's low, it should be%d.", B); } Else if(a==b) {printf ("Congratulatins"); } Else{printf ("guess it's high, it should be%d.", B); } return 0;}

Experiment Summary: Before writing the code, must adjust the good order

At the time of writing, remember what that variable means.

Learned a new function

&& | | Or did not make a quick distinction.

Summary of Knowledge points: Do not add semicolons after the IF statement;

To understand the usage of%d and%c

Third time job

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.