2016.06.06 Monday the C language sorts the strings from the ASCII code of the characters to the small size and prints out the total number of character types in the string

Source: Internet
Author: User
Tags sorts

The first variable conflict problem solved for one hours, ....

The code is as follows: ↓

#include <stdio.h>#include<string.h>#defineN 200//maximum length of the input stringintMain () {//************************ input Start part ********************************printf"Please enter a string. (length within 200) \ n"); intI=0, j,k,temp,lowletters=0, capletters=0, num=0, spechar=0;//defining a Count variable    CharStr1[n],str2[n];    Gets (STR1); //the string that receives the keyboard input is passed to the STR1 array//*********************** Sort Section ************************************strcpy (STR2,STR1);  for(k=0; K<strlen (str2); k++)         for(j=k+1; J<strlen (str2); J + +)        {            if(str2[j]>Str2[k]) {Temp=Str2[k]; STR2[K]=Str2[j]; STR2[J]=temp; }        }//************************ judgment type part *****************************     while(Str1[i]) {if(str1[i]>='a'&&str1[i]<='Z') {printf ("\t%c\t is a lowercase letter \ n", Str1[i]); Lowletters++; }            Else if(str1[i]>='A'&&str1[i]<='Z') {printf ("\t%c\t as capital letter \ n", Str1[i]); Capletters++; }            Else if(str1[i]>='0'&&str1[i]<='9') {printf ("\t%c\t for number \ n", Str1[i]); Num++; }            Else if(str1[i]<=127) {printf ("\t%c\t for special characters \ n", Str1[i]); Spechar++; } I++; }//*********************************** Total Statistics part **********************************printf"\n\n\t\t follows ASCII code from large to small after the string is:%s\n", STR2); printf ("\n\n\t\t string length is%d \ n", strlen (str1)); printf ("\t\t Total capital letters%d \ n", capletters); printf ("\t\t lowercase letters total%d \ n", lowletters); printf ("\t\t special characters total%d \ n", Spechar); printf ("There are%d \t\t numbers \ n", num);return 0;}

2016.06.06 Monday the C language sorts the strings from the ASCII code of the characters to the small size and prints out the total number of character types in the string

Related Article

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.