1 喜歡 0 不喜歡
9.6k 瀏覽

(20%)由於經濟不景氣,張三決定改行當個占卜師。但張三對於占卜術還不太上手,非常苦惱。請幫他設計一個程式如下:

請輸入一個日期,然後依照下面的公式:

M=月
D=日
S=(M*2+D)%3

得到 S 的值,再依照 S 的值從 0 到 2 分別給與 小吉(small)、中吉(medium)、大吉(big) 等三種不同的運勢。

input:

1 1

output:

small

 

[考試] 最新提問 分類:2017-1 程式設計(一)AD | 用戶: (30k 分)
ID: 43449 - 從幾時開始: 2018-01-19 18:30 - 到幾時結束: 2018-01-19 21:30

修改於 用戶: | 9.6k 瀏覽

21 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
* * * *** ** ** ** * ** M,D,S;
** ****** * * ** * * * * * ** %d",&M,&D);
* ***** ** * * * * ** * **
*** * * * ****** *
** **** ******* *** *
** *** ** ** * * * *** * *** ** ** * * * * ***
* * * * ** ****** **
* * * * * ** ***** if(S=1)
    {
* ** ** * * ** * **** * ** * * * * * ** ** *** * ** * **
* * *** * ***** * **
* ** *** **** * * * if(S=2)
**** *** * * *
** ** ** ** ** * ** * * * ** * ** ****** * ** * *
*** ** * * ** ** *** *
* ** *** * ** *** * 0;
}
最新回答 用戶: (202 分)
0 0
prog.c: In function 'main':
prog.c:5:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d %d",M,D);
             ^
prog.c:5:16: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]
     scanf("%d %d",M,D);
                ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
** * ** * * ** * * M,D,S;

* * ** * ** * * * * ** **** ** * %d\n",&M,&D);

* ** * * * *** * * *** * *
    {
* * ** * *** * (s=0){
**** ** ***** ** ** * *** * * *** * * ** ** **
    }
** * * * ** *** ** ** if(s=1){
**** **** * * ** * * * ** *** ** * ***** * *** ** *
*** **** *** * ** * * * ** * * *** *** **
*** * ** * * * * * * if(s=2){
**** **** ** * ** * ***** ** *** ** * * **** ***** * *
********** ******* * * ** * * ***

* ** * * *** ** ***** * *
**** * * *** *** * *** * * ** *** * * *** ***
** * ** * *** * ** ** *
****** * * * *** ** * * ** **** * *** * *
** * * *** * * * ** *** **** 0;
* **** * * *** ***** *
****** * * ** ** ** * ** * * *
    
**** ** ** ***** * * * *** 0;
** * * **** * * * *
最新回答 用戶: (194 分)
修改於 用戶:
0 0
prog.c: In function 'main':
prog.c:8:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int *' [-Wformat=]
     printf("%d",&S);
              ^
prog.c:12:14: warning: too many arguments for format [-Wformat-extra-args]
       printf("samll\n",&S);
              ^~~~~~~~~
prog.c:15:14: warning: too many arguments for format [-Wformat-extra-args]
       printf("medium\n",&S);
              ^~~~~~~~~~
prog.c:18:14: warning: too many arguments for format [-Wformat-extra-args]
       printf("big\n",&S);
              ^~~~~~~
prog.c:27:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 0
prog.c: In function 'main':
prog.c:8:20: warning: conversion lacks type at end of format [-Wformat=]
     scanf("(M*2+D)%3",&S);
                    ^
prog.c:8:11: warning: too many arguments for format [-Wformat-extra-args]
     scanf("(M*2+D)%3",&S);
           ^~~~~~~~~~~
prog.c:12:16: warning: too many arguments for format [-Wformat-extra-args]
         printf("samll\n",&S);
                ^~~~~~~~~
prog.c:14:16: warning: too many arguments for format [-Wformat-extra-args]
         printf("medium\n",&S);
                ^~~~~~~~~~
prog.c:16:16: warning: too many arguments for format [-Wformat-extra-args]
         printf("big\n",&S);
                ^~~~~~~
prog.c:21:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int *' [-Wformat=]
     printf("%d",&S);
              ^
prog.c:22:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 0
prog.c: In function 'main':
prog.c:8:20: warning: conversion lacks type at end of format [-Wformat=]
     scanf("(M*2+D)%3",&S);
                    ^
prog.c:8:11: warning: too many arguments for format [-Wformat-extra-args]
     scanf("(M*2+D)%3",&S);
           ^~~~~~~~~~~
prog.c:21:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int *' [-Wformat=]
     printf("%d",&S);
              ^
prog.c:22:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 0
prog.c: In function 'main':
prog.c:10:9: error: 's' undeclared (first use in this function)
     if (s=0){
         ^
prog.c:10:9: note: each undeclared identifier is reported only once for each function it appears in
prog.c:23:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
prog.c: At top level:
prog.c:26:12: error: expected declaration specifiers or '...' before string constant
     printf("%d",&S);
            ^~~~
prog.c:26:17: error: expected declaration specifiers or '...' before '&' token
     printf("%d",&S);
                 ^
prog.c:27:12: error: expected declaration specifiers or '...' before string constant
     system("pause");
            ^~~~~~~
prog.c:28:5: error: expected identifier or '(' before 'return'
     return 0;
     ^~~~~~
prog.c:29:5: error: expected identifier or '(' before '}' token
     }
     ^
0 0
prog.c: In function 'main':
prog.c:10:9: error: 's' undeclared (first use in this function)
     if (s=0){
         ^
prog.c:10:9: note: each undeclared identifier is reported only once for each function it appears in
prog.c:23:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
prog.c: At top level:
prog.c:26:12: error: expected declaration specifiers or '...' before string constant
     printf("%d",&S);
            ^~~~
prog.c:26:17: error: expected declaration specifiers or '...' before '&' token
     printf("%d",&S);
                 ^
prog.c:28:5: error: expected identifier or '(' before 'return'
     return 0;
     ^~~~~~
prog.c:29:5: error: expected identifier or '(' before '}' token
     }
     ^
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

int main()
{
* ** * * ** * * * * * date,month,sum;
* *** * * * ** ** **** ** **** * * * * *** * * **** ** **
* * ** * * ***
* ***** * ** * ** *** * ** * ** * * ** * * ***
* **** * ** * * * ** ** * ** * ****** ** ***** *** * *** * * ** * ** * * ** * * * *** **** ** ** * * ** *** * * *
    }

** ******* **** * * *** * 0;
}
最新回答 用戶: (114 分)
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
prog.c: In function 'main':
prog.c:4:11: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
     while(scanf("%d %d",&month,&date)!=EOF)
           ^~~~~
prog.c:4:11: warning: incompatible implicit declaration of built-in function 'scanf'
prog.c:4:11: note: include '<stdio.h>' or provide a declaration of 'scanf'
prog.c:4:40: error: 'EOF' undeclared (first use in this function)
     while(scanf("%d %d",&month,&date)!=EOF)
                                        ^~~
prog.c:4:40: note: each undeclared identifier is reported only once for each function it appears in
prog.c:7:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
         printf("%s\n",sum==0?"small":sum==1?"medium":sum==2?"big":"");
         ^~~~~~
prog.c:7:9: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:7:9: note: include '<stdio.h>' or provide a declaration of 'printf'
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
    int m,d,s;
** ****** ***** *** *** ****** %d",&m,&d);
    
    s = (m*2+d)%3;
    
    switch(s)
    {
** *** * ** * *** * * * * ** * **** *** * ** **** * ** **** ** * * 0:
* * ** ** * * * ** * ** *** * * * ** ** * * * * * ** ** ** **** * * ** ** * ** * * * *** * ** ** ** ** ** ****
**** ***** * * ** * *** * * ** *** ******* * * * ** ** * * ** * ** * ** ** * *** ********** ** * * ** *
* **** * * ** * *** * **** * * ** ******* ** ****** * * ** ** ** * * * * ** * ******* *
** ***** ** * *** * * ** * * ** * ** *** * * *** * * ********* ** * ** * 1:
* ** * ** * * * ** ** * *** **** * ** * * ** * ** * ** ** *** * ******* ** ** **** * * * * * *** * ***
*** ** ** * ** * * ** ***** ** ** *** * * * ** ** * * * * ** * * ** * ****** ** * *** *** * * **
** ** ** *** ** ** ** ** * * * ** **** **** * * * * * *** *** *** ** ** *** ** * * *
** ** ** * * ** * * ****** * **** * * * *** * ** * * ** * *** ** ** 2:
* ** * * *** * * * ** ** **** * * *** * ** ** *** ** ** ** * * * ** * * * * * * ** *** * **** * **** * **** ****
** * ** ** * * ** ** * * ********** ** * *** * * * * * *** * * * ** ** *** *
}
    
    return 0;
}
最新回答 用戶: (212 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include * ***** ** *
int main()
{
* ***** **** *** ** ** * m, d, s;
* ** ** ** * **** * * * *
** * * ** ** * ** * * * * * ** ****
*** * * * ** ** ** * *** * = (m * 2 + d)%3;
******* * * * *** ** < 1)
* *** * * ** * **** * * * * *
** ** * * * *** * ** * *** >= 1&&s <= 2)
* * ** * * * ***** ****** *** *
*** * * * * ** ** ** * > 2)
**** ** * * *** ** ** *** * * *
}
最新回答 用戶: (240 分)
0 0
prog.c: In function 'main':
prog.c:5:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d",m);
             ^
prog.c:6:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d",d);
             ^
0 喜歡 0 不喜歡
內容已隱藏
* * ** * * *

int main()
{
* ** * * int m,d,s;
** *** * * ** *** * * ********* **** ****
* * s= * * **
* ******* if(s==0)
**** * ** * * ****** ** * **
* *****   else if(s==1)
* ** * ** *** * * **
* * * * * else
* * * * * ** * * * * *** **
}
最新回答 用戶: (164 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main(void)
{
***** * ** ** ** m,d,s;
*** * * * *** ***** **** * %d",&m,&d);
* ** *** * * ** *** * **
*** ** * * *** **** *** *
***** * ** * **** * * ** *** * * * *** *
** **** ***** ****** * ******* if(s==1)
********* ** * *** ***** * ****** **** *****
** ** ** ** * * * ** *** if(s==2)
***** **** * * **** *** ** * * ** *** **
* ** * ** * **
* ** * * *** ** *** 0;
}
最新回答 用戶: (160 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

int main ()
{
** * * * * **** * * * ** m,d,s;
** ** *** * ** ****** * * * %d",&m,&d);
* ** ****** * = (m*2+d)%3;
* * ** **** * *** ** *** * * (s == 0)
** * * * ** *
** ****** ** **** * **** * * *** ** * *
*** ** ***** ** ** **
* ** ** ** ** ***** ***** * ** (s == 1)
* ***** * ** * * ****
* * * ** * ** * ** *********** * ** ** * **
**** ** ******* **** * *
* * ** * * ** *** *** * * (s == 2)
* * **** ** **** **
** ***** * * ** *** ******* ****** * * *
** * * ***** **** * *
   
* * ** * * * * *
* * * * * ** * *** * * 0;
}
最新回答 用戶: (196 分)
修改於 用戶:
0 0
prog.c: In function 'main':
prog.c:20:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

int main()
{
** * * *** * * ** ** m,d,s;
* **** * ***** ** ** *** ** * ** * %d",&m,&d);
* ** ** * ** * *** *** *** * *
**** ****** * ********** ** ***
*** * **** *** * ** * * **** * * ***
*** *** ***** * * * **** if(s==1)
* * * * **** ***** * ** ** *** * * * * * * *
** ** * ** * ** *** * * ** if(s==2)
* * *** * * * * * * *** * *** * ***
*** ** ** * * * * ** *** 0;
}
最新回答
修改於 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
    int m ,d ,s;
** ** ** *** * * **** * ** %d",&m,&d);
* * **** **** * **** **
* ** * * * * * ** ***** * ***
* **** **** * ** ** * ********* * ***** * ** * * *** *
* *** *** ** ** * ** *
** * ** ** * * * ** ******
** * **** * **** * * * * *** **** ** ** *** *
* ***** * * ***** * ** ****
* * * * * * * * **** * * * ***** ** * * ** * * * *** ****
* ***** ***** *** ** *** **** * *** * *
** *** * ** * * * * 0;
}
最新回答 用戶: (172 分)
重新顯示 用戶:
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.216.211
©2016-2025

相關問題

1 喜歡 0 不喜歡
24 回答
[考試] 最新提問 1月 19, 2018 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 43456 - 從幾時開始: 2018-01-19 18:30 - 到幾時結束: 2018-01-19 21:30
| 2.7k 瀏覽
1 喜歡 0 不喜歡
24 回答
[考試] 最新提問 1月 19, 2018 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 43455 - 從幾時開始: 2018-01-19 18:30 - 到幾時結束: 2018-01-19 21:30
| 2.4k 瀏覽
1 喜歡 0 不喜歡
24 回答
[考試] 最新提問 1月 19, 2018 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 43454 - 從幾時開始: 2018-01-19 18:30 - 到幾時結束: 2018-01-19 21:30
| 3.3k 瀏覽
2 喜歡 0 不喜歡
24 回答
[考試] 最新提問 1月 19, 2018 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 43453 - 從幾時開始: 2018-01-19 18:30 - 到幾時結束: 2018-01-19 21:30
| 2.6k 瀏覽
1 喜歡 0 不喜歡
23 回答
[考試] 最新提問 1月 19, 2018 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 43452 - 從幾時開始: 2018-01-19 18:30 - 到幾時結束: 2018-01-19 21:30
| 2.2k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶