0 thích 0 k thích
13.7k đã xem

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) - đã hỏi trong Chapter 8: Arrays bởi (5.2k điểm)
ID: 39985 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn

đã sửa bởi | 13.7k đã xem

31 Trả lời

0 thích 0 k thích
Hidden content!
#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] * ***** * *** * )


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

* * ** ** *** ** * ** * ** ******
* ****** **** *
}
trả lời bởi (-140 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
0 thích 0 k thích
Hidden content!
#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;
}
trả lời bởi (-168 điểm)
đã sửa bởi
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 thích 0 k thích
Hidden content!
#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;
}
trả lời bởi (-229 điểm)
đã sửa bởi
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 thích 0 k thích
Hidden content!
#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();
}
trả lời bởi (-214 điểm)
0 0
prog.c:3:19: fatal error: conio.h: No such file or directory
 #include <conio.h>
                   ^
compilation terminated.
0 thích 0 k thích
Hidden content!
#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;
}
trả lời bởi (-32 điểm)
đã sửa bởi
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 thích 0 k thích
Hidden content!
#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] ** *** * * **** * ** ***** )


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

*** ** ** * * * * * * * ** * * * **
* * ***** ****
}
trả lời bởi (-167 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
0 thích 0 k thích
Hidden content!
#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;
}
trả lời bởi (323 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
0 thích 0 k thích
Hidden content!
#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;
}
trả lời bởi (-193 điểm)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 thích 0 k thích
Hidden content!
*** *** ***
* * * ****** ** *** **

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, * ***
}
trả lời bởi (-285 điểm)
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 thích 0 k thích
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;
}
trả lời bởi (-284 điểm)
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.243.109
©2016-2026

Những câu hỏi liên quan

0 thích 0 k thích
102 trả lời
[Exercise] Coding (C) - đã hỏi ngày 28 tháng 12 năm 2017 trong Chapter 8: Arrays bởi semicolon (5.2k điểm)
ID: 39984 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 27.9k đã xem
0 thích 0 k thích
56 trả lời
[Exercise] Coding (C) - đã hỏi ngày 29 tháng 11 năm 2017 trong Chapter 8: Arrays bởi semicolon (5.2k điểm)
ID: 34913 - Xem được từ: 2017-11-30 18:00 - Hiệu lực đến: Không giới hạn
| 16.3k đã xem
12,783 câu hỏi
183,442 trả lời
172,219 bình luận
4,824 thành viên