ASCII sort, hdu-2000

Source: Internet
Author: User

Problem description Input Three characters, the ASCII code of each character is printed in order from small to large to output these three characters.

Input data has more than one group, each of which consists of three characters and no spaces between them.

Output for each set of input data, one line is printed, and the characters are separated by a space.

Sample INPUTQWEASDZXC

Sample outpute q wa d sc x z below is the code:
#include <stdio.h> #include <stdlib.h> #include <string.h>int main () {char a,b,c,d,max,min;while ( scanf ("%c%c%c%c", &a,&b,&c,&d)!=eof)//Here to add four variables, because there is one to be used to absorb the carriage return {if (a>b) {   max=a;   Min=b;} Else{max=b;min=a;    

  

The biggest difficulty of the problem is to consider the absorption of the carriage return, but I this method is more stupid, the following is the new method I learned!

#include <stdio.h>#include<stdlib.h>#include<string.h>intMain () {Chara,b,c,d,x,y,z;  while(SCANF ("%c%c%c%c", &a,&b,&c,&d)! =EOF) {x=a<b?a:b; X=x<c?X:c; Z=a>b?a:b; Z=z>c?Z:c; Y=a+b+c-x-Z; printf ("%c%c%c\n", x, Y, z); }return 0;}

Improved, really simple a lot of, but the above is my own thought out, or very fulfilling sense! Hope to bring you help!

ASCII sort, hdu-2000

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.