0 喜歡 0 不喜歡
10k 瀏覽

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

 

[練習] Coding (C) - 最新提問 分類:Chapter 8: Arrays | 用戶: (5.2k 分)
ID: 39985 - 從幾時開始: 無限制 - 到幾時結束: 無限制

修改於 用戶: | 10k 瀏覽

31 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include * * *
#include *** * * * **
#define Max 1000

void ** ** * [], int []);
void * * ***** [], int []);

int main()
{
* ** ** * ** * **** * ** * **
* * * ********** c, count[26] = {0};

**** * ** * * * *** ** * Max, stdin );

* *** ** ** * ******** count);
**** * *** ** * * count);


*** * * * * ***** ** (c = 0 ; c < 26 ; c++)


*** * ** * * *** * * *** *** * **
** ** *** * *** * * ** *** * **** ****** * * **** * * * ***
***** * * * * ** * ** **** *
* * ** ** * **** *** *** *** **** * * *** ** * * ** ** ** *** c + 'A', count[c]);
** *** ** *** * *** * * *
** ** ** * ** ** * * *** ** *** *** *
* * * ** * **** *** * * ** ******* ** * ** ****** ** * * * **** * c + 'A', * * **


* * * * *** * * * 0;
}
void * *** s[], int count[]) {
* * * * * * ****** c = 0;

* ** * ** * *** ** * (s[c] != '\0') {

* *** *** * ** ** * * ** ** ** * ** * (s[c] >= 'A' * ** * * s[c] <= 'Z'  )


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

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

void * ** * *** s[], int count[])
{

* * * * *** * ********* *** c = 0;

* * ** * * * * (s[c] != '\0') {

** ****** ** ** ** * ** *** * ** (s[c] * *** * ** * * *** )


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

*** * *** * * ******** ********* *
** *** * * * ***
}
最新回答 用戶: (-140 分)
0 0
Case 0: Correct output
Case 1: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include<string.h>
int main()
{
** *** ** * **** ** * ** i,c,r,s, tab[100];
* *** * ** * * a,chaine[1001];
** ** * * * ** * * ***** ****
* * * * *** ** * *** ** *** *
** * *** * * *** ** **
* * * * * * *** ** * *** * * ** * *
* ** * *** ** * * (a='a';a<='z';a++)
** * * * ***** **
* ** * *** * ******* * * * ***** ***** * ** * * *** * ******* * * *
* * * * ******** ***** **
*** * ** **** ****** * * * ** * ** ***** ** ** ((chaine[i]==a) || (chaine[i]==a-32))
* ** ** ** * * ** *** * ** ** **** * * * ** * * * * **
** * * *** * * ***
* *** *** * ****** ** * *
* * * * * * * * **
** ** * * *** * (c=0;c<=25; c++)
** *** *** * *** * ***** **
* * *** ** * **** * * * * ** * * *** * * *** * (c<25)
** ****** ****** * *** * *** * * * * ***** ** * *** *** %d\n",(c+65),tab[c]);}
** * * * *** * ** **** **** ** * *
* **** ** * **** * *** * ** *** *** * ** ** ** *** * * %d",(c+65),tab[c]);}
* *** * * ** ** **
** ** * **** *** ** * * 0;
}
最新回答 用戶: (-168 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
prog.c: In function 'main':
prog.c:7:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(chaine);
     ^~~~
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/ccLui6ys.o: In function `main':
prog.c:(.text+0x26): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:7:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(chaine);
     ^~~~
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/ccZnZnXG.o: In function `main':
prog.c:(.text+0x26): warning: the `gets' function is dangerous and should not be used.
0 0
Case 0: Correct output
Case 1: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <string.h>
int main()
{
**** * *** * ** * * * * * * *** * ** **** **** ** * * * ** ** * * *
**** **** * ***** ** ** * ** * *** ** **** ** * * ***** * * ** * *
    int c[50]={0};
****** ** * ** * ** * ** d[1000];
    int n,i,j,l,z=0;
** ** * **** *** * ** ***** *
* * * * ** * ** ** *
** *** ** ***** *** * (i=0;i<n;i++)
    {
******* * ** * ** ** * * * * **** * ** (j=0;j<26;j++)
*** ** * * * ** ** ** * * * * ** *
** ** * *** * * ** ***** * ****** * * ** *** * * **** * ***** * (d[i]==a[j]||d[i]==b[j])
* ** * ** *** * *** * **** * * * * ** * ** * * ** ** ** **
** ***** *** ** * ** ** * * ** *** *** * ** * * *** * * * * *** * * * * ** * **** **
** **** ** * ** * * * * *** * * * * ** *** * ** * **** *
*** * ****** ****** * **** * *** ** *****
    }
* ******** ** * * * ** *** (l=0;l<26;l++)
    {
*** ******* * *** * ** * * * ** ** * * (z==0)
***** ** * ** * ** *** ** ** * * * **
** ** * * ***** **** ** **** * ** * * ** * * ** * * * *** ** *** * * %d",b[l],c[l]);
**** ** * ** **** *** * ** ** ** * * * ** * ***** ***** * ** ***
** * ** * * * * * * * * * ** * * * * * *
** ** * *** ** * ** *** * *** * ****** * **
* * * ** * * * ** *** **** * * * * ** *** ****
* **** * * ** **** ** * ** * * * * * * *** * ** **** * *** ******* * * * ****** * %d",b[l],c[l]);
* * * *** * *** * ** ***** ** ***** *
    }
** **** * ** * * ** * 0;
}
最新回答 用戶: (-229 分)
修改於 用戶:
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: Correct output
Case 1: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include * * ** * * *
#include ** ** ** * ***** *
#include * * ****** *
#include * *** ** **
void * *** * ** src,char* dsc)
{
*** * ** * for(int i = * * * ****
*** **** dsc[i] = **** * *
}
int main()
{
* * * * char ****
* * * * ** ** char t[1000];
* ** ** ** gets(t);
** * * * * ** *
* ****  

* *** *** for(char * ****** **** *
* ** **** * {
** * * * * *** * * int count=0;
** ** ** *** ******* ***** for(int ***** ** * **
* * * *** ** ****** * {
* * ** * * * * * * ** ****
***** * * ** * ** * * * ** ** ****** **
*** ** * ** * * * * ** {
* ** * * * * * **** *** * ** * * * * * *** count++;
* ** * *** ** ** ** ** ** * }
**** *   * ** * * }
* ** ** *** ******* ***** ******* **
* *** * * *** * ** * * * * ** * *
**** ** * * ** ** * * ** * * * * * * * * * ** ** **** ***** *** *** **** ** * * * *
** ** ***** ** * **** * ** * * * ** *
* * * }
* ** * *
* * ** getch();
}
最新回答 用戶: (-214 分)
0 0
prog.c:3:19: fatal error: conio.h: No such file or directory
 #include <conio.h>
                   ^
compilation terminated.
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <string.h>

int A[26];//大寫
int a[26];//小寫

int main()
{
* * *** ** **** * * ** *** i;
*** *** ** ** ** **** n[10000];
** ** ****** ** ** ** * * ** * ** * *
** ** * ** ** * *** **** ** ***
* * ** **** * * **** **** * * ***
* **** * ** * * * ***** * * * **
**** ** **** *** * * * *** * ** * ** * * * * ** ** ** * *** * ** && n[i]<='z')
* * **** * ** * * * ** **** ** * * ** *** * ** * * *** ** ** *** *** ** ***** * ****
******** * ** * ** *** ** * * **** * * ** * ** * ** if(n[i]>='A' && n[i]<='Z')
* ** * * * * * * *** *** * * ***** ** * ** * ** *** ** ** * * * * *****
** * * ** *** * *
**** * **** ** * * * *** ****** * * ** * *
*** * ** * * **** * * ***** ** **** ** ** || a[i]!=0)
* * * * * ** * ****** * * * * * ** ** * ** * ****** *** %d\n",i+'A',A[i]+a[i]);

** *** * * ** ** **** * 0;
}
最新回答 用戶: (-32 分)
修改於 用戶:
0 0
prog.c: In function 'main':
prog.c:16:38: warning: multi-character character constant [-Wmultichar]
          else if (n[i]>='A' && n[i]<='Zq')
                                      ^~~~
0 0
prog.c: In function 'main':
prog.c:12:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(n);
     ^~~~
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/ccfK7LFr.o: In function `main':
prog.c:(.text+0x25): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:12:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(n);
     ^~~~
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/cc7Hbocl.o: In function `main':
prog.c:(.text+0x25): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:11:15: warning: format '%[^
   ' expects argument of type 'char *', but argument 2 has type 'char (*)[10000]' [-Wformat=]
     scanf("%[^\n]",&n);
               ^
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include * * **** * *
#include ** * **** *
#define Max 1000

void ** * **** [], int []);
void * * * ***** [], int []);

int main()
{
* * * * * * * *
** * * * * * c, count[26] = {0};

* * ** ***** **** * * Max, stdin );

*** * * *** * *** * *** * count);
*** * * * ***** * * ** * ** count);


* * * ** ** *** (c = 0 ; c < 26 ; c++)


* *** ** ** * * **** * * ** **** *
***** * ***** ***** ** * ** * * * * * * * * ** * *** ****
** * * * * ** * * *** * * *****
*** ** ***** * * * * * *** * * ** * ** ** * *** * * * * c + 'A', count[c]);
***** * *** ***** * * **** * * * *
******* *** * * ** * ** ***** *
* * * ** ** * ** ** *** ** * ** **** ** **** * ** ** ** * c + 'A', *** *


* ** * *** * ** * * 0;
}
void * * ***** s[], int count[]) {
***** ** * * ** * * c = 0;

**** * * * * * (s[c] != '\0') {

** * ** *** *** * * * ** ** * (s[c] >= 'A' ***** * * ****** s[c] <= 'Z'  )


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

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

void * ** s[], int count[])
{

* ** * * * ** ** ** c = 0;

******* * ** * * * * ** (s[c] != '\0') {

* * * * * * * * ** ** * * * *** ** (s[c] *** *** * * * * * ** )


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

***** * * * **** * **** *** ** * *
*** ** * * *****
}
最新回答 用戶: (-167 分)
0 0
Case 0: Correct output
Case 1: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
* ** ** ***** * * * ** ** * string[1000];
** ** * ** * * * ****** * c = 0, count[26] = {0}, x;
* * ** * * *
**** **** ** * *** ** ** * **** * *
* ** ** * * ** ******
* ** ***** * * * ** ** (string[c] != '\0') {
** ** ** ** * * * ****** * **** **** ** * * ***
* * *** ** ** * *** ** * * * * * ** * * ** (tolower(string[c]) >= 'a' && tolower(string[c]) <= 'z') {
** * * * ** * * * * ** ** * * **** ****** ** *** * * * * *** ** ** * = tolower(string[c]) - 'a';
*** * ** ** ** * * ** **** *** ** * ** ** * * **** * * ******* **
* ***** * ******** * ** * **** ***** * * * *
*** ** *** * *** * ** * ****** * ** * *
** * ** * * ** ** * * **** ** * *
* ****** ** *
* * * *** ** * **
* * * ** ** ***** * * * * * * (c = 0; c < 26; c++){
**** * *** * **** * * * * ** ** *** ** *** *
* * * ** * * * ** ** ** ***** * **** * * * * * * %d",c+'A',count[c]);
** * * ** ** * *** * * * *** ***** **** *
** ****** * * * * * *** * ** ** * * ** * *** * * (c != 25)
* *** * * ** ** * * ******* ** * *** * **** * **
** * ** ** *** *** *** ** ** ************ * **** ** * ** * * *** **** *
** ** * * * * ** ** *** * ** * ** *** * *
****** * * ** **** * *
    
* **** ** ** * * ** ****** 0;
}
最新回答 用戶: (323 分)
0 0
Case 0: Correct output
Case 1: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include * * **
#include ** ** * ** **

int main()
{
** ** * ** * * **** * * *** string[1000];
** * * ** * ** * ** c = 0, count[26] = {0}, x;
*** **** **** ***
* * * * * * *** ** * * ** *
* **** * * * **** * *
* ** * ** ** * *** * * (string[c] != '\0') {
* * **** ** ** * * * * * **** ***** **
* ** ***** * * * ** * *** ***** * ** * * (tolower(string[c]) >= 'a' && tolower(string[c]) <= 'z') {
* * ** * * * ****** **** ** ** ** * **** * * * *** ** * *** = tolower(string[c]) - 'a';
** ** **** * * ** * * ***** **** ** * **** ** * * ** *** * * * *
* *** ** ** * *** * ** *** ****** * *** * *** **
* * * * * * ** ***** * * ** * * ****
** ** ** ** ** ******* * **** * *
*** *** ****** *** ** * ****
***** *** * * ** * ****** **
* ** * * ** ** *** (c = 0; c < 26; c++)
* * * ** * * * ** * * * * ** * * * * ** * %d * * ** **** **
* *** * ** * ** ** ** *
* * ********** * * ** * ** * *** 0;
}
最新回答 用戶: (-193 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
* ** *** * ** * ***
* * * ** * ** *****

int **
{
** * char

* * ** ** ** ** * = **

** ** *** * * * *** *
* * ** ** * ****
* * ** ***** * int len = * *
* * * *
*** *** **** * int j = 0;

* *** * *** i = 0; i * * * i++)
* * ** ** {
**** ** * *** * * ** * ** = 0; j **** 26; j++)
* *** ** * ** * * ** ** {
*** * ** *** * * * * * * * * ** ** ** * == 'A' + j || * == 'a' + j)
** ** * * * * * * * *** * ** {
** * * ** * ** * * ** * ** ** * *** * * * * *
** * * * ** * ** *** ** }
** ** ** * * * * ** ** *** }
* ** * * }
*** * * **** ** = 0; j * 26; j++)
* * ** **** ** ** ***** * *** == 25)
****** * *** * * ** * * * *** * **** ** ** * **** * 'A' + j, *
**** * *** * *** * *** *
* * *** * **** * ***** * *** ** * * *** ** *** * ** ** * * * 'A' + j, *
}
最新回答 用戶: (-285 分)
0 0
prog.c: In function 'main':
prog.c:11:12: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
  int len = strlen(a);
            ^~~~~~
prog.c:11:12: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:11:12: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
Case 0: Correct output
Case 1: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#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;
}
最新回答 用戶: (-284 分)
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:172.69.130.93
©2016-2025

相關問題

0 喜歡 0 不喜歡
102 回答
[練習] Coding (C) - 最新提問 12月 28, 2017 分類:Chapter 8: Arrays | 用戶: semicolon (5.2k 分)
ID: 39984 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 22k 瀏覽
0 喜歡 0 不喜歡
56 回答
[練習] Coding (C) - 最新提問 11月 29, 2017 分類:Chapter 8: Arrays | 用戶: semicolon (5.2k 分)
ID: 34913 - 從幾時開始: 2017-11-30 18:00 - 到幾時結束: 無限制
| 11.9k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶