0 like 0 dislike
1.8k views
請撰寫一個程式,使用者會輸入一行字元,換行字元代表輸入結束,請計算所有的輸入當中有多少個英文字母,多少個數字,以及多少個其他的字元,並依照範例的格數輸出。

Sampile input:

1234567890ancdefghijklmnopqrstuvwxyz~!@#$%^&*()_+

Sample output:

digit:10
alphabet:26
other:13
[Exercise] Coding (C) - asked in 作業 by (18k points)
ID: 17578 - Available when: Unlimited - Due to: Unlimited
| 1.8k views
1 3
Called for Help

82 Answers

0 like 0 dislike
Hidden content!
#include<ctype.h>

#include<stdio.h>



int main(void){

    int digital = 0;

    int alphabet = 0;

    int other = 0;
** * * * * ** ** ** **** c;
* * **** ** * * *** * ** * * ** ** **


* ** ****** **** ***** * != '\n'){
* * * *** * ** * ******** * * ** * **** * **
** ** **** * ** * **** ** * ** * ** * ** * * * ** *** * * * ** *
**** ** * * ***** * * **** *** *** * **
* **** *** *** **** * * *** * * ** **** ** *** *** *
** * ***** ** * * ** *** *** * * **** * * ********* **** * * *
* * * *** *** ********* *** * * * * ** *
**** * * * * * ** ** ** ** *** * * * * **** **** == 0 && isalpha(c) == 0){
* * ***** * * * **** * * * * * ** * * * * *** * * ** * ** * **
* ** *** ** * * * * **** * ** *** * * * *
* ** * *** * * * ** * * ** * ** ** ****** * * * * ****

    }
****** ** * ** * *** *** ** * *** * ** ** *
* *** *** ** * * *** ** * * *** * * ****** **
* * * ***** ****** * ** ** ***** * * * **
* * ** ** * *** *** * ***** *** 0;

}
answered by (-216 points)
0 like 0 dislike
Hidden content!
#include<ctype.h>

#include<stdio.h>



int main(void){

    int digital = 0;

    int alphabet = 0;
** * * ** *** ** other = 0;
** *** *** * ** ** c = '\0';
* * * * **** * ** *********** * ** * ***


* *** **** ** * * **** * * != '\n'){
* *** ** *** * *** *** *** **** ** * * ** ** **
** *** * * * ** * **** ** ** ** *** ** ** ****** * * * ******* *
* ** * * * *** * * * ** * * * ** ** **** * * * ***
**** ** ** ** *** * * ******* ***** * * * * * **
** *** * * * * **** * * **** * * *** * **** *** ** *** * * *** **
* ** ** ** *** * * ** ***** ** **** *** *** ** ** *
* ** * ** *** * * *** *** * ** * ** ** * ** == 0 && isalpha(c) == 0){
* * * ** ** * ** ** *** ** *** **** * ** * * * * *****
***** * ** * ** * * ** * * * * * ** *
*** *** ** ** * * ********** * * * ** * * ** ** ** *** ** * **

    }
* ** **** * * * *** ** * ** * * ** * * * ** *
*** * * * * ** * * * * ** **** ** ** *
***** ** * ** * * *** **** **** * * ** * ****** *
** ** ** * ** ****** ***** * 0;

}
answered by (-216 points)
0 like 0 dislike
Hidden content!
# include <stdio.h>

# include <ctype.h>

void check ( char c);

int main ( void )

    {
*** ** ***** ** ** **** * * * * * *** *** * * * digit, alphabet ,other;
* ** ** * ** * ** * * * ** *** c;
* * * ******* * * ** ** *** * **** ** ** ("%c", &c);
* * * * ** *** ** * * ** * ** *** * * (c != '\n')
*** ** *** * * * * * * ** **** * * * * * * *
*** * * ***** * * ** * ** *** * * *** *** ***** * * ****** * * * * * **** * ("%c", &c);
***** ****** * ** * ****** * * ** * *** * * * ** ******* * * *** ******* ** * * * *** (c);
** * * *** ** ***** ** ** *** * * ***** ** * * * * ** * * *
* * *** **** * * * **** * **** ** * * **** * * ** * * * *** ** * ** ****** *** *** ** *** * ***** ** * ** **
** * * * *** * * * **



void check ( char c)

    {
* * ** **** **** ** ** * * * ** * * * ** * * digit=0, alphabet=0 ,other=0;
** *** *** *** **** ** ** ** ** ***** ** * ( isalpha (c))
* ****** *** *** *** ** * ** * * * * * * * * * ** * *** ** ****** **
** ** * ** ** ** ** *** * * ** * * * ( isdigit (c))
** ** ** * * *** ** ** * ******** ** * * * ** **** ** * ** * **
** * * * ****** ** * ** ** * ** * * ** * * * ( isspace (c))
********* ** ** ** * ******* * * * ** * * ** * * *** * * * * * **
** ** * * * ***** **** *** * ** ****** ( ispunct (c))
**** ** **** **** * ** * ** *** * * *** * * * * * * * * ***** ***
* ** ** * * ** * * **** * * * * * * *** * ** *

    }
answered by (-162 points)
0 like 0 dislike
Hidden content!
** * * ** ** **
**** * * *

void *** *** c)

{

printf * * * = ** **** c);
*** * ( isalnum (c))
** * ** **** isalnum * ** *
* ** * ( * ** (c))
*** * ** ** * ** ** * * * * ****
( ** ** (c))
** ** ** * * *** * * ** *** **
** ( ** * (c))
*** ***** *** ** **** * * *
* ***** ( **** (c))
* ***** ***** * ** isdigit * ** *


* * ( * (c))
*** * ** * * * * *** **
* *** *** ( ** (c))
** *** * ** * ** isprint **** **
* ** * ( isgraph (c))
* ** ** * * * isgraph ***** *
* * ( * (c))
* ********* * * * ** **
* *** ( * ** (c))
* *** *** ** ** * * * * ** ** *****

if ( *** (c))
** ** ** *** ** * *** * ** *
* *** * * * ;
* * *



int main (void)

{
* * **** c;
* ** ** ** i, j, k;
*** * ** * * * ******* ** * * **
*** ** * ( c != '\n')
* * * * * * * * * * * ***
*** * *** * * * **** ** * *
** * ** * *** ** * * * * * *


* **** * * * **** * *
** ** * 0;

}
answered by (-74 points)
0 like 0 dislike
Hidden content!
#include<stdlib.h>



int main()



{
* * ** ** * *** *** * c;

    int m=0;

    int n=0;

    int i=0;


*** * *** *** * * *** ** *** ** **** ** ***** *
* * * * * ** * ** * * * **

    {
** *** * * * * ** **** * *** ** ** * **** * * * * **** ** * ** ** * **** * * * * ** *** ****** * ** *
** * * * * ** * * ******** ** *** ** * * ** ** * ** ** * *
*** ****** *** * * * **** * **** ***** ** ** ** * **** * * ** * * *
*** * *** ** * ** ***** ******* ** ** *** * *********** *** * *
* *** * **** * *** * * * **** * * * **** *
** ** ** ** ** *** * ** *** ** *** *** * ** *** ** * ** * *****
* ***** * * ****** * * *** *** * * * *** ** **** ** ***
** ** * * * * *** * ***** ***
*** ** * * * **** * **** * * **** * ***** * * * *
* ** * * * *** ** ** * 0;

}
answered by (-100 points)
0 like 0 dislike
Hidden content!
#include<ctype.h>

#include<stdio.h>



int main(void){

    int digital = 0;

    int alphabet = 0;
*** ** * * ** * ** * other = 0;
* ** ** ** * * ** c = '\0';
*** * * ****** ** * * * ** * *


** * ***** ** * * * * != '\n'){
********* ** **** ***** *** * ** ** ** *
* **** ** ** * ** ***** * *** * * * **** ** * ** * * ** * ****
* * ** * * * * ** * * ** *** ** *
** * ** ** ** *** ***** * **** * ** * * * * * *
** * *** *** * * *** * *** ** * * * ***** ****** * **
** * ** *** * * * * * ***** ** *** * * ****
** * *** * ******* ****** * ***** *** * * *** *** * * * * == 0 && isalpha(c) == 0){
* **** * *** **** * * ** * ** ** ** * * * ** ***** ** * ** ****
** * * ** * * * *** * ***** *
* *** * ** ** * ** ** * *** **** * * * * *** ** ** * * * ** ******* **

    }
** *** * ** * ** * ** **** * * ** ** * *
* ** ** ** ** * ** * *** * **** *** * * * * ** *
* ** * * * * *** * * * ** ** *****
** ** ** *** * * 0;

}
answered by (-216 points)
0 like 0 dislike
Hidden content!
#include<ctype.h>

#include<stdio.h>



int main(void){

    int digital = 0;

    int alphabet = 0;
* *** * ** * *** * * ** other = 0;
*** ** * **** ** * *** * *** c = '\0';
** * * ** * ** *** * *** * * * * * * ***** * ** *


** * ***** ** * * != '\n'){
*** * * **** * * * ** *** * * ** ** * **** * * *** *
* **** *** ** * ** *** *** *** ** *** * ** ***** * ** * * *
** **** ** ****** *** ** ** ** *** * * ** ** **
* ** ** * ** *** * * * ** * * ** ***** * * *
* *** **** **** * ** * *** * * ** * ** ** ** ** * *** * *** * * *
* ** * * * * * ** ** ** * * * * * * *
* * **** * * **** * * ***** ** * * * * * * * ** == 0 && isalpha(c) == 0){
* ** * * * ** ** * *** * *** ** * * * **** * * *
***** *** * **** * * * ** ** * ** * ****** *
* * *** * ** * ** * ** **** * * **** * ***** * * * *** ** *** *

    }
* * * * * ** * * ****** ****** *** * *
* * * * ** ** * ********* **** * * * * **** * * ** *
** ** ** * * * * ** ***** ** ** ***** * **
** * *** * * * ***** * * * 0;

}
answered by (-216 points)
0 like 0 dislike
Hidden content!
#include<ctype.h>

#include<stdio.h>



int main(void){

    int digital = 0;

    int alphabet = 0;
** * * ** ** * *** other = 0;
*** * * ** ******** **** ** * c = '\0';
******** ** * * * * * ****** ***** * *** ***


* * * ** **** * ** * != '\n'){
* ** * * * * * *** * ** ** ******* *** *** *
** **** *** *** * ******* ** ** **** **** * * * ** * * * *** * * ** *
** *** ** **** *** * **** **** ** * **
* ***** * * * * *** * * **** * ** ** ***** * * ** *
**** ** *** *** **** * * **** * *** *** ** **** ** * **
** *** * * ** * *** **** * * * ******* * *
* * * * * * * * * ** * *** * *** * * * ****** == 0 && isalpha(c) == 0){
* * **** ** ** **** ** * * * * * ****** ******** *** ** **
* *** * * *** ** * * * * * * ** *** ** * *
** * ** *** **** ** ** * ** ***** *** * *** *** ** ** ** * * ** * *

    }
*** ** **** *** * ** * * * ******** *** ** **** *
** **** *** ** ** * *** * ** *** * * *
* *** * * ** * **** ** ** * * * * * * ** * *
** ** *** *** ** * * 0;

}
answered by (-216 points)
0 like 0 dislike
Hidden content!
#include<ctype.h>

#include<stdio.h>



int main(void){

    int digital = 0;

    int alphabet = 0;
*** ** * * * * ***** * * ** other = 0;
* * ** * * * * * ** * c = '\0';
**** * *** * ** * ** * * * **** * * * *****


* **** **** ** ***** ** * ** != '\n'){
*** *** *** *** ****** * * ** * ** * * ******* *** *
** *** * ** *** * * ** ***** *** * * * ***** * **** ** * ** * * ** * * * * *** ***
** ** ** ** * * * *** *** * * *** **
* * *** * ** * ** * ** ***** ****** ** * * * ** * *
**** * ** * ***** ** ** ** * ***** *** *** *** ** **** * * *** * ***** * ** *** *
** * * *** ** ** * ** * * * * *
* **** * * **** * * ** * * *** * * * ** **** * ******* == 0 && isalpha(c) == 0){
* ** * *** *** * *** **** *** ** **** *** ** * **** *
**** * ** * * *** * * ** * * *** *** *
* **** *** ** ** * * * *** * * * *** **** *******

    }
* ***** * ** * * * * * ** * ** ** ** ***
*** * **** **** * ** ***** **
* * *** * * * * ** ** **** ** *** *
*** ** ** * ** * * * ** * 0;

}
answered by (-216 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <ctype.h>



int main(void){

    char c[100];

    int num=0,s=0,i;
* * **** * * * *** ** **** *** ** * * * *

    for(i=0;;i++){
** * * *** ***** * ** * ** * * * ******* *****
**** ** ** * * * *** ** **** ** * * ** * * *** **** ** *
* ***** ** ** * * ***** * * ** * ** * *
** ***** * ** * * ** ** * *** * ** * * **** **
** * ****** ****** * * * * ** ****** ** * *** * * * * * *** ** *** * **** * **
*** ***** * * * * ** * * * * ****** *** * **** * * * *** * * ** * *** ** * *** * ** *** *
*** ** * ** ** * ** * *** * * ** * * ** ** * ** ** ** ***** **
* * * * * * ****** * ** ** ** * ***** * * ** * * *** * * * ** * * *
** * *** * * * * * ** *** * **** * * * * ** * * * ** **** *** ** * * * *** ****
*** * *** *** **** * ** * ** *** *** * * ** * ** ** * *
** ** *** ** * * * * **** ** * *** ** *

    }
*** * ** * * ** *** ** * * ** ** *** ** *** ** * *****



    return 0;

}
answered by (-126 points)
0 0
用字元:

#include <stdio.h>
#include <ctype.h>

int main(void){
    char c;
    int num=0,s=0,o=0,i;
    scanf("%c",&c);
    while( c != '\n'){
        if(isalpha(c)){
            s++;
        }
        else if(isdigit(c)){
            num++;
        }
        else{
            o++;
        }
        scanf("%c",&c);
    }
    printf("digit:%d\nalphabet:%d\nother:%d",num,s,o);
    return 0;
}
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.7.141
©2016-2024

Related questions

0 like 0 dislike
0 answers
[Exercise] Essay (Open question) - asked Dec 28, 2016 in 作業 by Shun-Po (18k points)
ID: 20139 - Available when: Unlimited - Due to: Unlimited
| 171 views
0 like 0 dislike
20 answers
[Exercise] Essay (Open question) - asked Dec 21, 2016 in 作業 by Shun-Po (18k points)
ID: 19748 - Available when: Unlimited - Due to: Unlimited
| 691 views
0 like 0 dislike
26 answers
[Exercise] Essay (Open question) - asked Nov 9, 2016 in 作業 by Shun-Po (18k points)
ID: 17203 - Available when: Unlimited - Due to: Unlimited
| 811 views
0 like 0 dislike
0 answers
[Exercise] Essay (Open question) - asked Dec 28, 2016 in 作業 by Shun-Po (18k points)
ID: 20140 - Available when: Unlimited - Due to: Unlimited
| 142 views
0 like 0 dislike
3 answers
[Exercise] Essay (Open question) - asked Dec 21, 2016 in 作業 by Shun-Po (18k points)
ID: 19755 - Available when: Unlimited - Due to: Unlimited
| 226 views
12,783 questions
183,443 answers
172,219 comments
4,824 users