0 like 0 dislike
13.2k views

Write a program that ask the user to input a serial character (max 1000). Prints a table showing how many time each digit appears in the number. You should see 'A' and 'a' as the same.

寫一個程式 求使用者輸入一字串(最大1000) 輸入字母出現的次數 (A跟a算一樣)

Example input

Write a program that ask the user to input a serial character. Prints a table showing how many time each digit appears in the number. You should see 'A' and 'a' as the same.

Example output

A 19
B 2
C 3
D 3
E 15
F 0
G 3
H 9
I 9
J 0
K 1
L 3
M 5
N 7
O 6
P 5
Q 0
R 10
S 10
T 13
U 5
V 0
W 3
X 0
Y 2
Z 0

 

[Exercise] Coding (C) - asked in Chapter 8: Arrays by (5.2k points)
ID: 39985 - Available when: Unlimited - Due to: Unlimited

edited by | 13.2k views

31 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>
char string[1000];
int ii,jj;
int ** * * * * ** * * ** ** ** * ** * ** * * * ***
int main()
{
    fgets(string,1000, stdin);
* * * **** * * ** ******* * * *** *
***** * * **** ***** * ** * ** ** * ** * * **** ** * ****** ** **
*** * * * ***** *** * **** *** ** *** *** * **** ****** ** ********
**** ** * * **** ** ** **** * * * * * ***** ****** **** *** *
** ** ***** * * * *** ** *** * ** *** * ** * * * *** *******
** ** * * * ** **** * * * * ** * ** * ** * ******* * *** **** ***
******* ** ***** *** *** * ** * * * * ** * * **** * ** *
** * * * ** * * * * **** * * * *** ** *** ******* ** *
*** * * *** * ** * *** * ** * ** * * * ** * ***** * * *
* ** *** *** * ** *** * * ***** * * ** ** ** * *** ***** ** *
* * * * * * ********* ** ** * ** ** **** ** * * * ** *** ** **
* * ** ** * * ** ****** ** ** *** * *** ** * ** ***** ** * **** * * **** * *
* **** * ** * *** * * * ** * ** * * * * * * ** * * ** * ** *
* **** ** **** ** * *** * ** * ** ** * * ** * * * * * ** *** * *
* ** * * ** **** ** ** **** *** * ** * * * ***** ** **** ** * * *
** * * * * * ** ***** * * ******** * * * * * * ** *** * ** * * *
** ** * ** * **** ***** ** ** ** * * * * * ** *
* * *** ** * * * *** ******* ***** * ***** * **** * ** * * * ** *
* ** *** ** * * ****** ** **** ** * *** **** ** * * * ** * **
***** **** * ** **** ** ***** * ** * * **** ***** * ***** ** ** * * **
** * ****** *** * *** *** ** * **** ** *** ** ** ****** ***** ** *
** * ** ** ***** * ** * * * * ** ** * ** **** **** * *** * * * ** *
** ** *** ** ** * * *** * *** * * * * **** ** ** ******* * * ** * * **
* ******* *** * *** * * * ****** * ** ***** * **** * *** ** *****
** * ** ** **** * ** * **** * * * ** * * * *** **** * *** ******* * * ****
*** * *** *** **** ** *** * * * * * **** * *** **
*** *** * *** *** ** * ** ***** ** * * ** * ****** * * * * ** *

    }
    printf("A %d\n",a);
    printf("B %d\n",b);
* * **** ** **** * ** * ** **** %d\n",c);
*** ** * * ** * * ** ** ** **** * %d\n",d);
** **** * ** ** * * %d\n",e);
*** ******** ** * * *** * * ** %d\n",f);
*** * * *** *** ** * ** * ** ** %d\n",g);
* * ******** * ** * * * %d\n",h);
* ***** * * ***** ** ** * * ** **** * %d\n",i);
** ******** **** * ** ** * ** * %d\n",j);
**** * * * *** ** ** * ** * ** * %d\n",k);
* ** ********* ** ** * * * ** **** %d\n",l);
** ******** * **** **** *** * **** *** %d\n",m);
* * ** * *** *** *** %d\n",n);
* **** ** * ** ** **** *** * %d\n",o);
** * ** * **** **** ** * *** * ** %d\n",p);
* ** ** *** ** **** ** * * * * * %d\n",q);
* **** * * *** * ********* *** * * * * %d\n",r);
* ** *** ** ** ** ** * * ***** %d\n",s);
* * ******* **** * * ** * * ** * * %d\n",t);
** * * * * ** ** ** * ** * * * * %d\n",u);
* ** * *** ** *** * * * * * %d\n",v);
    printf("W %d\n",w);
    printf("X %d\n",x);
    printf("Y %d\n",y);
* * ***** ** ** *** * * *** **** %d",z);

    return 0;
}
answered by (-108 points)
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>
char string[1000];
int ii,jj;
int * ** ** * * * * * *** *** * * * ** ** ** * * *** **** ** *
int main()
{
    fgets(string,1000, stdin);
***** * ** * *** ** * * * *
* * * ** ***** * ***** **** * ***** * * ** ** * ***** ** ***** *
* ** * ** * * ** * * ** ** * *** ** ** ** ** ** * **** ** * *
* * *** * * * * ******* * ** * * *** * *** * ** * * * **** * **** *
* ** ** ** ** * * ** ** * * * ** ***** * **** *** ** * ** ** *** *
** **** *** * **** * * **** * * * **** * **** * *** * * *
** * ** **** *** *** **** * * ** * **** * ** * * ***** **** * **
****** * *** ** ** * *** * * ** ** ** ** ** * * ** *
**** ** * ** *** ** * *** ***** * * *** * * * * ***** * **** **
* **** ***** *** * * * * ** ** ** ** * * ** *** * ***
* * * *** * **** **** ** ** **** * *** *** ** ** ** *
* ** **** ** * * ****** ** * ** *** ** * * * *** * *** *** * ** *** ** * *** **
** * ** * * ** * * ** * ** * **** * * * * * ** ** * * **
* * **** ***** * ** ** ** * ******* ** * * * *** ****** * * **** *
* ***** ** * * * * * * * * ** ** * * *** * ** * ** * *** *** * * *
*** * ** ** * * ** * * * ** ** ** * * * ** ** * ** ** * ** ***
* *** **** ** ******* ** * *** ** ******* * **** * ***** ** * ***
* ** ***** * * ** * ** * * * ** * * * * * * * ** * **** *
* ** * * **** *** *** * ** * **** * * * *** * *** * ** *
** *** * * * *** ** * *** ****** **** ** * * * ****** * * *
** *** * *** *** * ** *** **** ** ** *** * *** * ** * * ** * * ***** * *
* *** * * **** ** **** *** *** *** * *** ** *** * * *** * *** *
** * * ** * * *** ** *** ** * **** * * * ** * * ***** ** *
** ** * * ** *** ** *** * * * * * ***** ***** * ****** * ** *
* ** * * ** * * * * ******* * ** ** *** * * * * **
* * * * * *** *** *** * ***** ** **** ****** ** * * ** * ** * **
**** ***** ** * ** * ** ****** ************ **** ** *** ** *****

    }
    printf("A %d\n",a);
    printf("B %d\n",b);
** * ** * **** * **** ** * *** ** %d\n",c);
* * ** * ** * * * %d\n",d);
**** * * * * *** ** *** ** * * %d\n",e);
*** ** * **** * *** * * * * * * * %d\n",f);
**** * ** * *** ** ** * *** * %d\n",g);
** ** * ** *** * * * ***** ***** *** * %d\n",h);
** ** ***** * **** * * ** * %d\n",i);
* ** * ** ** **** * ** * %d\n",j);
** *** * * **** ** * * %d\n",k);
********* *** * ** ** ***** * * ** %d\n",l);
** * **** ** ***** * *** ** * ** %d\n",m);
* *** **** * ** * *** * * * %d\n",n);
*** ** * * * **** * ** ***** * %d\n",o);
*** ****** ****** ** * * * * * %d\n",p);
*** ** * * * ** * * **** *** %d\n",q);
*** * * * * ** * * * *** * * %d\n",r);
** * * * * ***** **** * * *** %d\n",s);
* * * *** * * * ** * * * * ** %d\n",t);
* * * ***** ** ** *** * ** * %d\n",u);
* *** **** * * ****** * ** %d\n",v);
    printf("W %d\n",w);
    printf("X %d\n",x);
    printf("Y %d\n",y);
** * * * * * * * * ** ********* %d",z);

    return 0;
}
answered by (-258 points)
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
# include <stdio.h>
# include <string.h>

int main()
{
*** ** * ***** **** * * a[1000];

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

**** * ** * ******* ** letter;

****** ***** ** ** * * *** ** * * **
    {
*** * ***** * ** ****** * ** * * * *** * * *** k,count=0;
*** * * * ** ** ** * *** ** ** * ** ** * * * * *
* *** * * *** ***** ***** **** * ***** * *** * *** * *
**** ** ** ** **** *** **** *** ** ***** *********** * ** **** ***** * * * ** * * * * * *****
** * * * * ** * **** ** **** ** *** * * *** * * * **** *** * * **** **
** * ****** * * ** ***** ** *** *

* ***** * ** * * ***** * ** ****** ** *** ** * ** ** ***
* * ** *** * * * ** ** * ** * ** ***** ** * * * * %d\n",letter,count);
**** * * * ** * *** * * * * * * ***
*** **** *** * * ** * *** ** * ** * **** ******** ** * ** %d",letter,count);
    }

* * ** *** * * ** *** 0;
}
answered by (-16 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
int main(void)
{
** *** * * * * **** * ** * alp[26]={0},i,k;
**** * *** **** ** ** * **** * * *** *** *** * ***** *** * ** *** ** * **
**** ** * ** **** **** * ** ** * * ** * ** ** ** *** * ** ******* ** * * **
* * * * * ** * ** str[1000];
* * * * *** * *** * * * ** *** *
* ** * * ** *** * n= strlen(str);
* * * * * * **** * ** ** * **
    {
* * **** * * * * * * ** * ** *** * * * * * *
**** *** * ** * ** * ******* ** *** * *
* ** * **** *** *** * * ** *** **** ** * *** * * * * * *** * * (str[i]==cap[k] || str[i]==sm[k])
** ** * * ******* * ** ** * * * * *** ** * *** * * ** * * *** * * ** ** * ** * *** ******** ****** ** *
* * * ***** * * * ** *** *** *** * **
    }
* * * * ** ***** * *** ***
    {
** ** * * * ** * **** * * ** ** **** ** * **** * * %d",cap[i],alp[i]);
* * * * ** * * ** **** ** * * ** ****** **** * * * * * * * * * * **
** * * * ** **** * * * * * *** ** ** ****** * * * * * * * * * * ******** * * * * ** ** * * ** ** * *
    }
** *** ** ***** *** * ** ** ** 0;
}
answered by (-304 points)
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
* * *** * *** ** *
* * * ** ** * * *
* * * **** ***

int main()
{
char a[1000];
* * *** * ***
int len = * **
int e[26] = {0},i,j;
for(i = 0 ; i * * len ; i++)
{
** ** ** * *** * *** *** * = 0 ; j < 26 ;j++)
*** ** ** ****** * * * ***
** ** **** * * ** * * *** ** *** * ***** ** == a[i] || 'A'+j == a[i])
* ** ** * * ** ******* * * ** * * ** ** *** * ** ** * ** *** * *** **
* * ** ** *** * ** **
}
for(j = 0 ; j ** 26 ; j++)
{
* * *** * **** *** ** == 25)
** ** ** ** * ** * ** * **** * ** * * ****** * ** ** * * * *** *
* * **** * * ****** * *
* ** * ** * *** ***** * * ** *** *** *** *** ** * **** * *
}
** *** * * ** * **** *** * * 0;
}
answered by (-127 points)
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
# include <stdio.h>
# include <string.h>
# include <ctype.h>
int main(void)
{
** ** **** ** ** ***** * * str[1000];
**** * ******** **** * i,count[26]={0};
** * ** * ** ***** ** *** *
****** * * *** *** * * ** * **** * **** **
** ** * ** **
* * *** * *** ** ** ****** * * ** * ***** ** * * * ** * * * * * ** **
* * ** ** **** ** ** * ******* *** * * **** ** ** ** * **** ** *** * * ** * *
* * * * ** * * * ****** * * ** * *** * * * ** if(str[i]>='a' && str[i]<='z')
**** * * ** *** * * ***** ****** * ** * * * * * ** *** * ** * * *** **** * * * ** ** *** ** * * ** *** *** *
***** * ******** *
* *** ** * ** * * * * *
** * ** * ** ******* **
***** * * ** ** * * ** **** * ** ** ** ** * * * * * %d",i+'A',count[i]);
* ** * * ** *** *** * * ** * ***** ** * * **
*** * * *** * * ** * * ** ******* * **** * * * ** ** * *** * * * * * ** **
    }
******** ** * * * * * 0;
}
answered by (-281 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
You have extra line at the end of ouput
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
**** ** ** *
int * *
{
** ** ** * * char * * * *
* *** * ** * * int ** *
* * ** * ** ***** ** ***
* **** int i;
** * * **** * ** * ** * * * * ** * ** * ****
**   {
* ** * ** * *** * * * * *** *** * ** * * ** **** || * ** ***** *** * ** ** **** ** * * * * ** ')
*** * *     * * {
* * * * * ** ** ******* * * * * * * ** * * **
* * * ** * * * * * * ** ** {
***** * * ***** * ** * ***** * * * * * * * ** ***
* *       * **   }
* * *           else
* **   ** *** * * * * ** * *** {
* *** ** ** *** * * * * ** * * * **** ** * * ****
** ** * **** ** *** ***** ** *** * * }
* *** ** * ** * }
* * *** ** * }
*** ** *** int j;
* * ** ** ** ** ***
** * *** *** * * {
***** * *** * ***** ****** * ** ** * * *** * *** **
*** *** ***** if(j!=25)
* ** *** * * * ** *** *** * ***
* * * * * }
* **** * *** return 0;
}
answered by (-249 points)
edited by
0 0
prog.c: In function 'main':
prog.c:7:2: warning: 'gets' is deprecated [-Wdeprecated-declarations]
  gets(word);
  ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccmUJkGw.o: In function `main':
prog.c:(.text+0x4f): warning: the `gets' function is dangerous and should not be used.
0 0
Case 0: Correct output
Case 1: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
****** * **** * *** str[1000];
******* * *** ** ******* * i,count[26]={0};
*** ****** *** * * * * * * *** ** ***
* ***** *** * * ** *** * * ** *
*** ** * * * * **** ** *
** * * * ** *** * **** ** * * * *** * ***** (toupper(str[i])>='A' && * * * * ** * **
*** * ** * ******* *** ** ** * * ** * *** * * *** * *** ** * ** * * * * ** * ** **
* * ** ***** ** * ** **
** ** ***** * * * (i=0;i<26;i++)
** * *** * * ** **
** ** ** *** ***** * * ** * * ****** ** * ** * * ** ** * * ** * * ****** * *
* ***** * ** ***** ** ** ** *** ** * * (i<25)
** * ** * ***** * * ** * ** **** ** *** **** * * ** * * ** *** *** ** * *** **
**** **** * ** **** *****
* * * * * *** * * ** ** 0;
}
answered by (-249 points)
edited by
0 0
prog.c: In function 'main':
prog.c:12:19: warning: implicit declaration of function 'tolower' [-Wimplicit-function-declaration]
                 x=tolower(string[c])-'a';
                   ^~~~~~~
0 0
Case 0: Correct output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
0 0
prog.c: In function 'main':
prog.c:9:16: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     for (i=0;i<strlen(str);i++)
                ^~~~~~
prog.c:9:16: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:9:16: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
***** * **
** * ** * * ***
*** * **** ** *

int main()
{
char a[1000];
* *** **** *
int len = * *
int e[26] = {0},i,j;
for(i = 0 ; i **** len ; i++)
{
** * * * * * ** ** = 0 ; j < 26 ;j++)
* * * ** * * *** ** ****
* * **** ** *** * *** * ****** **** * == a[i] || 'A'+j == a[i])
* **** * * * *** ** * *** ***** * * ** *** ** * * * ****** * *
* * *** * ** ** **
}
for(j = 0 ; j ** 26 ; j++)
{
** ***** * * *** * * * == 25)
**** * *** ** * * ** * * ** * ** * * **** * *** * ** ** * ***
* * ***** * * ** * * ***
****** *** **** ** ** ** * *** * * ** * * ** ** * * * * * ** **
}
* ** * ** ** ****** * 0;
}
answered by (-255 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
** ** ** * *** * *** a[999];
* ** * * **** **** * **** ****** *** * *

********* * * * letter;
** ** *** ** * * * ** * * * ** * * **
    {
* **** * * *** ****** ********** * **** ***** i, lettercounter=0;
* ** * * ** ****** ** * ****** ** ** * *** * ** **
* * * ***** ** ** * * *** * ** *** ** * * **
* ***** * **** ** * ***** *** *** * *** * ** * *** ** * * * ***** * **** || a[i]==letter+32)
** * ** *** * ** * ** ** *** * * ** * * ** * *** * * * * ***** ** ** * ****** **** *** ***
* * ** *** ** *** ** * ***** * ** *** *
*** * ***** ** * * **** * %d\n",letter,lettercounter);
    }

** ** * * **** ** ** *** **
*** **** * ** ** * * ** i, lettercounter=0;
* * ** * *** * ** ** * *
* * * * * * * ** * * **
* * ** **** *** * ******* * * *** * * * *** ** * || a[i]==letter+32)
** **** * ** * ** * * * **** * ** ** ** *** * ***** *** ***
    }
*** ** **** *** ** *** * %d",letter,lettercounter);


* ** ** *** *** * *** 0;
}
answered by (-196 points)
0 0
Case 0: Correct output
Case 1: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.197.65
©2016-2026

Related questions

0 like 0 dislike
102 answers
[Exercise] Coding (C) - asked Dec 28, 2017 in Chapter 8: Arrays by semicolon (5.2k points)
ID: 39984 - Available when: Unlimited - Due to: Unlimited
| 26.9k views
0 like 0 dislike
56 answers
[Exercise] Coding (C) - asked Nov 29, 2017 in Chapter 8: Arrays by semicolon (5.2k points)
ID: 34913 - Available when: 2017-11-30 18:00 - Due to: Unlimited
| 15.5k views
12,783 questions
183,442 answers
172,219 comments
4,824 users