0 喜歡 0 不喜歡
12.8k 瀏覽

Finish the function compute_GPA below. The function should return the average of the grades (assume that A=4,B=3,C=2,D=1, and F=0). The grades array will contain letter grades (A,B,C,D, or F, either upper-case or lower-case 大寫小寫), n is the length of the array

寫compute_GPA函數。函數會return成績平均(A = 4, B = 3, C = 2, D = 1, F = 0)

#include <stdio.h>
float compute_GPA(char grades[],int n)
{
   /*INSERT YOUR CODE HERE*/


   /*END OF YOUR CODE*/
   //The function should return the average of the grades(assume that A=4,B=3,C=2,D=1, and F=0).
}

int main(void)
{
   char G[100];
   int n;

   /*INSERT YOUR CODE HERE*/


   /*END OF YOUR CODE*/

   printf("%g",compute_GPA(G,n));

   return 0;
}

Example input: 

The first input is the number of elements need to compute GPA (4); The array values follow; 

第一行是成績數目,第二行是成績(A/B/C/D/F)

4
A B C D

Example output

2.5

Remember: You may correct the cases, but your code always be revised!

[練習] Coding (C) - 最新提問 分類:Chapter 9: Functions | 用戶: (5.2k 分)
ID: 37278 - 從幾時開始: 2017-12-14 18:00 - 到幾時結束: 無限制

修改於 用戶: | 12.8k 瀏覽

50 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include * **** *** *
float compute_GPA(char grades[],int n)
{
* * * *** * ** * * *** * * i;
** * ** ** * ** gpa=0.0 ;

**** * **** *** * * **** * (i=0;i<n;i++)
* * **** ** *
*** * * ** ***** * ** * * ***** ** * * ** ** * **** == 'a') || (grades[i] == 'A')){

** * **** * ** * * ** ******* * * **** ** **** *** ***** **** ** 4;
** * ** * * * ** * * * * * * *** *

* * ** ** ** * ** * ****** ** * ***** *** * * * * * == 'b') || (grades[i] == 'B')){

* * * ** *** * *** * * * * ** * **** * ** ** *** * * * * * 3;
****** * ** ***** * ** ** * * ****

* * * * *** ** ** ** **** ** * *** ***** *** ** ** * ***** == 'c') || (grades[i] == 'C')){

*** **** * * * * ** ** * * * **** * **** ** ** * * * *** *** 2;
* ** * * ** ** *** * * * * * * * *

** ***** * * ** ** * *** ** ***** ** **** * if((grades[i] == 'd') || (grades[i] == 'D')){

******** ** * * ** ******** * ** *** ** * * * *** **** **** * * * 1;
* ****** ** * * *** **** *** * * *** **

* *** * * * ***** ** ** * * * * ** * ** ** * *  if ((grades[i] == 'f') || (grades[i] == 'F')){

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

***** * * ** * * * **
* ***** ** *** ** * * * gpa/n;


*** * **** * OF YOUR CODE*/
***** * *** ** * ***** function should return the average of the grades(assume that A=4,B=3,C=2,D=1, and F=0).
}

int main(void)
{
* * **** * * * ** ** ** G[100];
***** *** * ** * ** * * n;
** ****** ** * *** ** i;

* * *** * ** *** *** ** * * * * &n);
** ** ** *** ** ** (i=0; i<n;i++)
** *** * ** ** * * * * * *** * *** **** %c", &G[i]);

* ** **** *** ** * * * * OF YOUR CODE*/

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

* ** * ** *** ** ** *** * * 0;
}
最新回答 用戶: (-140 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
float compute_GPA(char grades[],int n)
{
* **** **** **** av;
   float a,b,c,d;int i;
* * * * * * * ***** ** *
   for (i=0; i<n; i++)
   {
* ** * * ** * ** *** ** * * * **** (grades[i]=='A')
* **** * * * * * * * * *** ** ** *
* ****** * * ***** ** ***** *** * * ** **** *** * * *
* *** ** **** * ** *** *** ** * **
* * * * ** ** ** * * * * **** **** * * * ** *
*** * ** ********* * ** ** ****** * **
* *** **** * * * * * * * * ****** ** * ** * * *** ***** * ** ***
** ******* * * *** * **** * *
* ** ** *** ** * * * ** *** * * *** *** * * * ***
**** **** * ** ** * * * *** * * **
***** * ** * * ** * ******* * ** *** *** ** * * * *** ** ****
* ***** *** * * * ** * ** ** ** * * *
*** * ** * * ** * ****** * * * ** * * (grades[i]=='D')
** * * * * * * *** **** * * * ** * **
** ** *** * * ** ** * * * *** * ** **** ** **** ** ** * * * ** * * *
** * ***** ** * * * ***** *** * * *
   }
**** * * * * *** *** * * *** *** * **** * * * ***** * * *** *** *
* ** * *** * * * *** ** ******** * **** * av;
}

int main(void)
{
   char G[100];
   int n,c,v;
*** **** ** ** * *** *** * * ****** &n);
   v=0;
   for (c=0; c<n; c++)
   {
* ** **** ***** * **** * * * ** ** *
**** **** ** ** **** ** **** * *** ** * * *
**** ** *** ***** ** * * *** ** ** ***** **** * * * * **** ***** *
* * * ** ** ****** * ** * * *** * ***
* * *** ** * * * * ** ** * * ** *
* * * * *** ** ******** * **
* ** ** * * * **** ** * * ** * * * *** * ** ** ** **** ** ** * ** * * ****** * G[c]);
*** * ** *** ** * ***** * * ******* * ** *
*** * * * ** * ** **** * * ** * **
   }

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

* **** * * * 0;
}
最新回答 用戶: (-168 分)
0 0
prog.c: In function 'main':
prog.c:40:16: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat=]
        scanf("%s",G[c]);
                ^
prog.c:44:22: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat=]
              scanf("%s", G[c]);
                      ^
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
float compute_GPA(char grades[],int n)
{
* ******* * * *** ** i;
* **** ****** *** * ** sum=0;
*** * ** *** **** *** **** ** *
   {
* **** ** * * ** **** ** * * ** *** ** *** * *
** * *** **** ** * *** * * ** * *** * * *
** * *** **** * **** * * * * *** * if(grades[i]==98||grades[i]==66)
* * ** * ** ** * * ***** ** * ** * ******* * **
* * ** ** ** * *** ** * *** * if(grades[i]==99||grades[i]==67)
** * *** * *** ** ** * * * * * * **** * * ***
* * * * ** * * * ** * ** * ** * * * ** * ** *
** * * *** ** ** * ** * * * * * ***
   }
* * * * ** ******* * **** sum/n;
}

int main(void)
{
**** * * * * * * G[100];
** *** * *** * n,i;
** **** ****** **** ** ***** * * ** ***
* **** * ****** * * * * ** * *
* * * * **** ******** * * *** **** * * ** * ****
** * *** ****** **** *** *** ** ** * ** *** *

* * * ** * **** 0;
}
最新回答 用戶: (-32 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
float compute_GPA(char grades[],int n)
{
   int i;
* * * * * ** ** * * * * sum=0;
* *** * ** ** ** * ** * * * ** * * *
   {
* ** ***** * *** * * * **** ** * ******* * *** * ** * *
* * *** ***** * ** * * * ** ** * * ** ** * * *
* **** ** *** *** * * * **** *** **** * ** **** * **
** * *** * *** ** * *** ** * ** * *
* *** * *** *** * ******* * *** ** * **** * ** **
* ** ** *** * ** ** * ** * * * *** ** * ** *
** * * * **** * * ** * * *** * * *** ** ** * ** *** * *
* *** * ** * ** ** * * * * * * **** * *** ** * * * **
* * **** ******** * ** * * * ** ** if(grades[i]=='F'||grades[i]=='f')
** * ** ***** * * * * ** * * ** * ** * * ** *****
   }

* * ****** (sum/n);

}

int main(void)
{
* * ** *** * * ** *** G[100];
   int n,i=0;

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

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

* *** ****** * ** * ** 0;
}
最新回答 用戶: (-16 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Correct output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:33:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'double' [-Wformat=]
    printf("%s",compute_GPA(G,n));
             ^
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
float compute_GPA(char grades[],int n)
{
*** * * * ***** * i;
* * * * ****** *** * gpa=0.0 ;
    
*** ** ** * (i=0;i<n;i++)
* ** *** ** * * *** *** ****
* * ** * ** *** * * ** * * * **** ****** **** * *** *** == 'a') || (grades[i] == 'A')){
** * * ** ** ****** ** ***** ** *** * * * * ** ** *** * *** * *
******* * * * * *** * * * * * ****** ** ** **************** 4;
******** * * * ** * * * ** * ***** * **
* * * ** * ** *** ** * * * * * * **
*** * * **** * * **** *** * * ***  if((grades[i] == 'b') || (grades[i] == 'B')){
* * * * ** ** * * * * **** ** * *** ** * *** * * * ** ** ** * **
**** ** *** ****** *** * * ** *** * **** ** * * ** ** ** ** ***** 3;
** * * * **** ** ** **** * ** **** *** ** ***
** ** *** **** *** ** ** *** *** * ******
*** * **** *** * ** * *** * ** * ** **  if((grades[i] == 'c') || (grades[i] == 'C')){
** *** ** ** * *** ** * ** ** ** * * * *** * ** *** **
****** * * ** ** ** * ** * ** *** ** * ** *** * ** * ** **** ** 2;
***** * *** * * ** ** ** * *** ** **** ** **
* * ** * ***** ** * ** *** **** * ** **
*** ****** * ***** * * * * *** ** * * ** * ** if((grades[i] == 'd') || (grades[i] == 'D')){
* ** ** * *** * * *** ** ** *** ***** ** *** ** ** ** *
* ** * * * * ** * *** ** * * ** * *** ** *** * *** *** ******** 1;
* * **** * **** ** * * * * * *** **** ***
***** * *** * * * *** ** * * *** * * * * * **
** * * * **** * * **** * ** * *** ** ** ***  if ((grades[i] == 'f') || (grades[i] == 'F')){
* ** ** * * *** * **** ** **** *** ** **** ** * ** * * ***
**** **** * ** * * ******** ** * ** * * * * ** * ** * * *** ** * * ******* 0;
* * **** ** * * * * * * ** ****** ***
** *** * * *** * * * ***** * ** ** ***
* *** * * ** ** *
**** *** * ** ** * gpa/n;
    
* * * * **** ** ****
* * **** **** ** **** OF YOUR CODE*/
**** * ** * * *** *** * * function should return the average of the grades(assume that A=4,B=3,C=2,D=1, and F=0).
}

int main(void)
{
* * * * * * ** * ** G[100];
** ** * * * ***** * n;
** ** * ** **** ** * i;
    
** * ** * *** ** ** *** * **** * *** &n);
** ** * ** * **** * * *** * (i=0; i<n;i++)
* * * * * * * *** * * ** *** *** * * *** ** * *** ****** %c", &G[i]);
    
** * * ** * * * ***** *** * *** OF YOUR CODE*/
** * ***** * * ** * * *
* * *** *** * * * ** *** * * ******* * *
    
***** ** ** ** **** * 0;
}
最新回答 用戶: (323 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
float compute_GPA(char grades[],int n)
{
***** * * * ** avg = 0;

***** ** * **** * * * ******** sum = 0;

* * * **** ** ** ** * * i = 0;

** *** ** *** * * * * m = 0;

* * ** * * *** * *** = 0; i < n; i++)
* *** ** *** * * **
**** *** **** * ** * * * ***** * * * * ******** ***** == 'A' || grades[i] == 'a')
* * * **** ** ** * ** *** *** *** * **
*** * ** ** * ********* *** * *** *** * * ** **** ****** ** * * * = 4;
** *** * * * * * ** **** * * *
* * * ** * ** ** * **** ** * ** *** if(grades[i] == 'B' || grades[i] == 'b')
** * * *** ** * *** **** * * * * ** * * *** *
* ***** **** * * *** * ** **** * * * ** ** **** * ** * * ** * = 3;
** *** * * * * *** * * * **** *** *** ** * * *
*** ** * * ** ** ** ****** ** *** * ** * if(grades[i] == 'C' || grades[i] == 'c')
* **** * ** **** ** ** * * * * *** ***
**** ** ** * * *** ** * ** **** *** * ***** ** ** * ** ******* **** * = 2;
*** *** *** *** ** ****** ** ** * * ****
** * * * *** ** * * * * **** ** ** ** *** if(grades[i] == 'D' || grades[i] == 'd')
**** * * ** * *** * *** * ** * *** * *
** * * * ***** * ** ** ** ** * * ** ** * ** ** * **** ** * * * ** **** = 1;
** ** * * **** * ** *** ******** * * *** ** ** **
* * *** * * * ** * *** * * * * **** ** ** **
** ** ** * ** *** * ***** **** ** * *
** ***** * * ** * * ** **** * * * * * *** *** ** *** * * *** = 0;
* ** ** * *** *** *** **** *** *

** ** * **** ** **** * * * * * *** * ** * * += m;
    }

* * * * * * ***** * * ** = sum / n;

* *** ***** ** ** * avg;
* ** **** ** * *** * *** function should return the average of the grades(assume that A=4,B=3,C=2,D=1, and F=0).
}

int main(void)
{
** **** * ****** *** ** G[100];
** ** *** * * ** * n;

* * ** ** ** * * YOUR CODE HERE*/
* * * * * *** **** * **** * **** * &n);

* * * ***** * * * * i = 0;

** ** * ** * ** *** * = 0;i < n; i++)
    {
******* * ** **** * * ** ** ** **** ** * ** * *** ** *** ** * &G[i]);
*** *** *** * * *


***** **** * ****** OF YOUR CODE*/

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

*** ** * **** * * 0;
}
最新回答 用戶: (-108 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
float compute_GPA(char grades[],int n)
{
****** * * ** **** * ** avg = 0;

* ** * * **** sum = 0;

* ** * * ** * ** * i = 0;

** **** *** * ** * ** m = 0;

**** * ** ** *** * * ** = 0; i < n; i++)
*** * *** *** ** * * **
** * * ** ******** ** * ****** * == 'A' || grades[i] == 'a')
* ** * *** * *** ** * ** * ** ** *
** *** ****** *** * ** ***** * ***** * ** * ******** ***** **** *** ** ***** = 4;
* *** *** * * *** ** ***** *** * * ** * **
** * * * *** * ** ** * ** ****** ** * ** if(grades[i] == 'B' || grades[i] == 'b')
** * * * * * ***** ** ** * *** * * ***** * *
*** ** * * ** **** ** ** ** *** * * ****** * * ******* ** * ** * = 3;
* * ** * * *** ** * ** * * * ** ********
** * * * * **** * ** * ** * ** * * * ** if(grades[i] == 'C' || grades[i] == 'c')
** * * * * * ** * * * * ** * **** * **
* ** **** ** *********** ** * * *** *** * ** ** ** * *** *** * * * * = 2;
* ** * * ** * * * ** ****** ** * *** * *****
* *** ** ** * * ** *** * ** * * * if(grades[i] == 'D' || grades[i] == 'd')
** *** * * * *** **** ** *** * * ** *
*** * * *** * ** * ******** *** * * * ** * ** * *** ** * * * = 1;
* * *** * *** *** **** * * * * * * *
* ** * ** **** ** * * * **** * * ** *** * *
*** * * *** *** * * * *** * *** **** * *
** * ** * **** * *** * * *** ** ** * ** * * * * ***** * * * * = 0;
**** **** ** * * ***** ** * * * **** * ** ******

*** * * ** * ** ** ** * * ** * ** ** ***** * * * += m;
    }

* * * * * ** = sum / n;

* * * * * * *** *** * * avg;
* *** ** * * * ** *** * ** function should return the average of the grades(assume that A=4,B=3,C=2,D=1, and F=0).
}

int main(void)
{
* * ****** ************ * G[100];
* * * * *** ** **** * ** n;

*** * * ***** ** **** YOUR CODE HERE*/
**** ***** ** * * * * * **** ** &n);

** ** ** * * *** * ** * i = 0;

* * **** *** * * * *** ** = 0;i < n; i++)
    {
* * **** * ** * **** * * *** * ** * * * * ** ** &G[i]);
* * *** * ** ** *** ****


** * ** *** * * * *** * OF YOUR CODE*/

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

* ** **** * ** ****** * 0;
}
最新回答 用戶: (-284 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
float compute_GPA(char grades[],int n)
{
* ***** * ** * *** * avg = 0;

* * ** * * * ** ***** **** * ** sum = 0;

* *** * * * * * **** * i = 0;

* ** * *** * ** * ***** m = 0;

**** *** ***** *** * * = 0; i < n; i++)
* ****** * * * ** *
********** *** * ** * **** * *** * * ***** **** ** == 'A' || grades[i] == 'a')
******* * ** ** ** *** ** * * *
* *** ** *** * * ** *** ** * * * ** ** ** * ** * * = 4;
* ** ** ** * * * ****** ** ** *** *** *
** * * * ***** **** * * * ** * * * * * if(grades[i] == 'B' || grades[i] == 'b')
** **** ** * * * ** * ** ****** * *** **** * **
* * * * ** *** * ***** ** * ** ** * * ****** ** *** ** ** * * ** * = 3;
* * * * * **** * *** ** * ** *** ** * *
* ** *** * ** * * * ** *** * ** ** * * * if(grades[i] == 'C' || grades[i] == 'c')
** * ***** ** * * **** * * ** * ****** *** ** *
*** ***** * * ** * ** * * ** ** * * * *** * ** * *** ** * * = 2;
* * * ******** * * *** ** ** * ** *** *
** * *** * **** ******** ** **** * *** * ** * ** * if(grades[i] == 'D' || grades[i] == 'd')
* * * ** ** ****** * *** * * * ** * *** * * * *
* * * *** * * * **** ** *** ** *** * * **** ** * ** **** ** ** = 1;
* ** ** * ** ** * * *** * ** * ** * ** ** * *** *
* ** *** * **** *** **** * ** * ****** * *
** ** **** ** ** ** * *** ** * *** * * * ** *
*** *** * * * ** * * **** *** * ** ** * *** * * * * * * * *** * ** = 0;
* ** ** * ** **** * ***** **** * * * *

** * * *** * **** * ** * *** *** *** *** * ** *** * * += m;
    }

* * ***** * * ** *** * ** = sum / n;

* * * ** ** ** **** ** * ** avg;
* *** ** ** ** ** ** ******* function should return the average of the grades(assume that A=4,B=3,C=2,D=1, and F=0).
}

int main(void)
{
** ** * *** * ** G[100];
**** * * ** ** ** ***** * * n;

* ** **** *** * *** ***** ** YOUR CODE HERE*/
* * ** ****** * ** * * *** ** ** ** &n);

** ** ** ** ** * * * i = 0;

** * * ** ** ** ****** * = 0;i < n; i++)
    {
* * * **** * ** * * * ** ****** **** ** **** * * ****** &G[i]);
** *** ** * * ***


* * ***** * ** * * ** * OF YOUR CODE*/

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

*** * **** * ** * * *** 0;
}
最新回答 用戶: (-323 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<string.h>
#include <stdio.h>
float compute_GPA(char grades[],int n)
{
   int i;
* ** * ** * * * sum=0;

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

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

* ******* *** * * * * **** * * * *** ** if(grades[i]=='B')

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

*** ***** * ******** * * ***** * ***** ***** if(grades[i]=='C')

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

* * **** * * ** ******** * *** ** * ** if(grades[i]=='D')

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

* ** ** ** * * ** * * ******** * **** if(grades[i]=='F')

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

* ** ** * * * * * sum*2/n;

*** * ** * ** **** * function should return the average of the grades(assume that A=4,B=3,C=2,D=1, and F=0).
}

int main(void)
{
*** * * ** *** * *** G[100];
* * ** * * * ** n;

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


** * * ** * * OF YOUR CODE*/

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

** ** *** ** ** ** *** 0;
}
最新回答 用戶: (-323 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Why??
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:42:4: warning: 'gets' is deprecated [-Wdeprecated-declarations]
    gets(G);
    ^~~~
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__;
              ^~~~
prog.c:43:6: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
    n=strlen(G);
      ^~~~~~
prog.c:43:6: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:43:6: note: include '<string.h>' or provide a declaration of 'strlen'
/tmp/cca4V36e.o: In function `main':
prog.c:(.text+0x169): warning: the `gets' function is dangerous and should not be used.
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
* * * ** **
** * * * ***** n)
{
** ** * *** avg = 0;

***** * * * * sum = 0;

**** *** * * *** int i = 0;

**** int m = 0;

* ** * ** = 0; i ** n; *
*** * {
* * ** * * **** * * * == 'A' || ** == *
** * * ** * ** ** ** {
** ** * * ** * ** * ***** * m = 4;
* *** *** ** *** * }
* * * * * *** * *** * *** * * **** == 'B' || ** * == *
* *** ** * * * ** * * {
* ** *** * **** ** **** ** ** * ** m = 3;
** ** * * *** * **** ** }
* * *** * * * * * * * * ** == 'C' || ** ** * == 'c')
* * * * *** * * * {
* * ** ** * ** * ** * * ** m = 2;
** ** * * * ** * }
* * ** * *** *** **** * ***** * == 'D' || * * ==
* *** *** * * {
* **** ** * ** *** * * * * ** m = 1;
* *** * *** * * * }
*** * ***** * * * * * *** * **
* * ** * ** *** ** * {
** ** * ** * * ** * **** * * m = 0;
** * *** ** * ** * ** }
* * ** * ** ** ***
* * ****** * ** ***** sum += m;
* ** * }

* * * ** *** avg = sum / n;

*** * * * * * *** ****
***** ** * * ** *** ** * the **** of the *** * ** * * ** * ** and ***
}

* *
{
** * * * ** *
* * **** * int n;

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

**** * * * int i = 0;

*** * *** **** = 0;i n; i++)
** * * {
***** * ****** * * * * ** *** * * * ** * ** * ** **
* ** * * }


* ** * * *** * ** OF YOUR * *

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

* ** * ** ** * * 0;
}
最新回答 用戶: (-285 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.80.196
©2016-2026

相關問題

0 喜歡 0 不喜歡
38 回答
[練習] Coding (C) - 最新提問 12月 13, 2017 分類:Chapter 9: Functions | 用戶: semicolon (5.2k 分)
ID: 37277 - 從幾時開始: 2017-12-14 18:00 - 到幾時結束: 無限制
| 9.1k 瀏覽
0 喜歡 0 不喜歡
41 回答
[練習] Coding (C) - 最新提問 12月 14, 2017 分類:Chapter 9: Functions | 用戶: semicolon (5.2k 分)
ID: 37370 - 從幾時開始: 2017-12-14 18:00 - 到幾時結束: 無限制
| 9.1k 瀏覽
0 喜歡 0 不喜歡
45 回答
[練習] Coding (C) - 最新提問 12月 7, 2017 分類:Chapter 9: Functions | 用戶: semicolon (5.2k 分)
ID: 35784 - 從幾時開始: 2017-12-07 18:00 - 到幾時結束: 無限制
| 10k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶