Third time job

Source: Internet
Author: User
Tags uppercase letter

1. Character judge input a character, judge if it is lowercase letter output its corresponding uppercase letter, if it is uppercase letters output its corresponding lowercase, if it is the digital output number itself, if it is a space, output "space", if not the case, output "other".
#include <stdio.h>intMain () {CharC; printf ("Please enter a character:"); scanf ("%c",&c); if(c>='a'&&c<='Z') {C=c- +; printf ("%c", c); }    Else if(c<='A'&&c>='Z') {C=c+ +; printf ("%c", c); }    Else if(c>='0'&&c<='9') {printf ("%c\n", c); }    Else if(c==' ') {printf ("space\n"); }    Else{printf ("other\n"); }        return 0;}

2. Age issue enter a student's birthday (year: Month: Day), and enter the current date (year: Month: Day) to calculate the actual age (years) of the birth.
#include <stdio.h>intMain () {inta,b,c,x,y,z,m; printf ("Please enter today's date:"); scanf ("%d%d%d",&a,&b,&c); printf ("Please enter your birthday:"); scanf ("%d%d%d",&x,&y,&z); if(a-z==0) {printf ("you're 0 years old ."); }    Else    {        if(b>y) {m=a-x; printf ("you're%d years old.", M); }        Else if(b<y) {m=a-x-1; printf ("you're%d years old.", M); }        Else        {            if(c>=z) {m=a-x; printf ("you're%d years old.", M); }            Else{m=a-x-1; printf ("you're%d years old.", M); }        }            }     return 0;}

3. Judging the triangle type enter three integers to determine the type of triangle (equilateral triangle, isosceles triangle, isosceles right triangle, right triangle, general triangles, and non-triangles)
#include <stdio.h>intMain () {intA,b,c; printf ("Please enter three number:"); scanf ("%d%d%d",&a,&b,&c); if(a+b<=c| | b+c<=a| | a+c<=b) {printf ("Non-triangular"); }    Else    {        if(a==b&&b==c) {printf ("equilateral triangle"); }        Else if(a==b| | c==b| | a==c) {printf ("isosceles Triangle"); }        Else if(a*a==b*b+c*c| | b*b==a*a+c*c| | c*c==b*b+a*a) {if(a==b| | c==b| | a==c) {printf ("isosceles Right Triangle"); }            Else{printf ("Right Triangle"); }        }        Else{printf ("General Triangles"); }    }    } 

4. See commodity guessing price games

#include <stdio.h>#include<stdlib.h>#include<time.h>intMain () {intb;    Srand (Time (NULL)); A=rand ()% -; printf ("Please guess the price:"); scanf ("%d",&b); if(a==b) {printf ("Congratulations, you guessed it."); }    Else if(a>b) {printf ("I'm sorry, you guessed small, right is%d", a); }    Else if(a<b) {printf ("I'm sorry, you guessed it, right it's%d .", a); }    return 0;}

Additional questions: Bug eating apple problem (complete this question plus 1 points) you bought a box of n apples, unfortunately, when you bought the box into a bug.   Insects can eat an apple every x hours, assuming that the worm does not eat another one before eating an apple, how many complete apples do you have after y hours?   Enter N,x and y (all integers) to output the remaining number of apples. Test data: 10 4 9 5 3 16
#include <stdio.h>intMain () {intn,x,y,m; printf ("Enter the number of apples:"); scanf ("%d",&N); printf ("Enter an apple time to eat:"); scanf ("%d",&x); printf ("input total Length:"); scanf ("%d",&y); if(n<=y/x) {printf ("Hahaha , your apples are eaten."); }    Else if((float) y/x>y/x) {m=n-y/x-1; printf ("you have%d left .", M); }    Else{m=n-y/x; printf ("you have%d left .", M); }    return 0; }

Ii. Summary of knowledge points in this course

1. Lowercase letters to uppercase need-32, uppercase to lowercase to +32;

2. #include<time.h> and Srand (Time (NULL)) are required to obtain random numbers;

3. Character constants should be represented by single quotation marks.

Iii. Summary of the experiment

1.else without brackets;

2. If it is char, you need to enter%c instead of%d;

3. is equal to two equals sign, an equal number is the meaning of assignment;

4. Write a program to write down the approximate steps of that question on paper;

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.