8 like 0 dislike
5.2k views
若一個正整數的奇數位數字和與偶數位數字和兩者差的絕對值是11的倍數,則這個正整數就是11的倍數,否則就不是11的倍數。

請寫一個程式來判斷輸入的數是不是十一的倍數。

 

輸入說明:

會輸入一個正整數N,N不會超過1000位。

 

輸出說明:

如果輸入的數字是11的倍數就在螢幕上輸出YES,否則就輸出NO。

 

輸入範例:

11111111111111111111111111111111111111111111111111

 

輸出範例:

YES
[Exam] asked in 2017-1 程式設計(一)AD by (18k points)
ID: 36178 - Available when: 2017-12-08 18:30 - Due to: Unlimited
| 5.2k views

19 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>
double n;
double main(void)
{
* * ** **** * ** ***
* ** ** ** * ** ** ** * ** m,s,i,j,sum1,sum2;
* * * ** *** ** k[n];
* *** * ** * *** ** *** * ** * ** * *
    
    
** * *** * * *** * ** * ** ** ***** * *
*** *** * ** * ** *** ******** ** *
* * * ** * ** * * * *** ** * * **
* *** *** ** ** * ** * *** ** ***** ****** ***
*** * *** ** ** * * * ** * *** * *****
** * * * *** ** * ** *** **
** ** ** * ** ***** * ***
*** *** ** * * * * *** **** * ** *** *
*** *** ** * **** * * ** ***** *** * ** *** *** * * **
* ** * *** * ** **
* ** ** *** ** * ** *** ** ** ** * ** ** *** **** **
**** *** * * * * *** * *
* * * ** ** *** * ** * ** * ** ** **
   
    return 0; * * **** ** * ** * * *** ** * * * ** ** **** *
 }
answered by (144 points)
edited by
0 0
prog.c: In function 'main':
prog.c:22:2: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
  system("pause");
  ^~~~~~
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
0 0
prog.c: In function 'main':
prog.c:22:2: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
  system("pause");
  ^~~~~~
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
prog.c: In function 'main':
prog.c:6:9: error: size of array 'k' has non-integer type
     int k[n];
         ^
prog.c:7:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
0 0
prog.c: In function 'main':
prog.c:6:12: error: size of array 'k' has non-integer type
     double k[n];
            ^
prog.c:7:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:4:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '>' token
     int m,n>0,s,i,j,sum1,sum2;
            ^
prog.c:5:11: error: 'n' undeclared (first use in this function)
     int k[n];
           ^
prog.c:5:11: note: each undeclared identifier is reported only once for each function it appears in
prog.c:10:9: error: 'i' undeclared (first use in this function)
     for(i=0,j=1;i<n,j<n;i+=2,j+=2)
         ^
prog.c:10:13: error: 'j' undeclared (first use in this function)
     for(i=0,j=1;i<n,j<n;i+=2,j+=2)
             ^
prog.c:12:8: error: 'sum1' undeclared (first use in this function)
        sum1+=k[i];
        ^~~~
prog.c:13:8: error: 'sum2' undeclared (first use in this function)
        sum2+=k[j];
        ^~~~
prog.c:16:5: error: 's' undeclared (first use in this function)
     s=sum2-sum1;
     ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:6:9: error: size of array 'k' has non-integer type
     int k[n];
         ^
prog.c:7:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
0 0
prog.c: In function 'main':
prog.c:6:9: error: size of array 'k' has non-integer type
     int k[n];
         ^
prog.c:7:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
0 0
prog.c: In function 'main':
prog.c:7:9: error: size of array 'k' has non-integer type
     int k[n];
         ^
prog.c:8:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
0 0
prog.c: In function 'main':
prog.c:7:12: error: size of array 'k' has non-integer type
     double k[n];
            ^
prog.c:8:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
prog.c:13:15: error: array subscript is not an integer
        sum1+=k[i];
               ^
prog.c:14:15: error: array subscript is not an integer
        sum2+=k[j];
               ^
prog.c:18:10: error: invalid operands to binary % (have 'double' and 'int')
     if((m%11==0)||(s%11==0))
          ^
prog.c:18:21: error: invalid operands to binary % (have 'double' and 'int')
     if((m%11==0)||(s%11==0))
                     ^
0 0
prog.c: In function 'main':
prog.c:7:12: error: size of array 'k' has non-integer type
     double k[n];
            ^
prog.c:8:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
prog.c:13:15: error: array subscript is not an integer
        sum1+=k[i];
               ^
prog.c:14:15: error: array subscript is not an integer
        sum2+=k[j];
               ^
prog.c:18:10: error: invalid operands to binary % (have 'double' and 'int')
     if((m%11==0)||(s%11==0))
          ^
prog.c:18:21: error: invalid operands to binary % (have 'double' and 'int')
     if((m%11==0)||(s%11==0))
                     ^
0 0
prog.c: In function 'main':
prog.c:7:12: error: size of array 'k' has non-integer type
     double k[n][n][n];
            ^
prog.c:7:12: error: size of array 'k' has non-integer type
prog.c:7:12: error: size of array 'k' has non-integer type
prog.c:8:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
prog.c:13:15: error: array subscript is not an integer
        sum1+=k[i];
               ^
prog.c:14:15: error: array subscript is not an integer
        sum2+=k[j];
               ^
prog.c:18:10: error: invalid operands to binary % (have 'double' and 'int')
     if((m%11==0)||(s%11==0))
          ^
prog.c:18:21: error: invalid operands to binary % (have 'double' and 'int')
     if((m%11==0)||(s%11==0))
                     ^
0 0
prog.c: In function 'main':
prog.c:7:12: error: size of array 'k' has non-integer type
     double k[n];
            ^
prog.c:8:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'double *' [-Wformat=]
     scanf("%d",&n);
             ^
prog.c:13:15: error: array subscript is not an integer
        sum1+=k[i];
               ^
prog.c:14:15: error: array subscript is not an integer
        sum2+=k[j];
               ^
prog.c:18:10: error: invalid operands to binary % (have 'double' and 'int')
     if((m%11==0)||(s%11==0))
          ^
prog.c:18:21: error: invalid operands to binary % (have 'double' and 'int')
     if((m%11==0)||(s%11==0))
                     ^
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
** *** ** ***** ** ***** *** n;
   n>0  &&  n <= 9^1000;
* ** ***** * * * * ** * *** * ** * *** *
   
** *** *** * * * *** * * ** ** *** ** ** % 11 == 0)
** * * *** *** * *** ** * ** * *** **** ** ** * *** ** **** * **
* **** * * * ** ***** * *** ** *****
** * * * * ***** * **** ** * ******* ***** *** **** ** * * *
** * * * * ** * * **** *** ** * *** * * **
* *** * *** * * ** ** * * * * ******** *** ** * 0;
* *** * *** ******* **** * *** ** * **** ***
* * * **** ** * * * ** * * * * *** *
answered by (131 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{
    char arr[1000];
** **** * *** * ** ** ** ***** ** ** * ** * ** **
    int i,x=0,y=0,z,count=0;
** **** *** ** * * *** ***** * ***
    {
** *** *** ** * * * * ** * *** * ***** * * * * * **
* ** ** * ** * ** * * ** ** * *** ** *** * *
*** ** * * **** * ** *** ** * ** * * ** * **** * * * *** ** ** ** * *
** * * * ** ** *** *** * * ** *** ** **** * ** **** * ***** ** * * **** *
*** * ******** * ** ** *** ** * *** **
*** ** * ** ******** ** ** ** * * * **** ***
** * ***** * * * ***** * * *** * * ** *
** * * ** *** ** * ** ****** * * *** * **** * * ** **** * * **
* **** ** * ** ** ** ** ********* * ** * * * *** * *** * *
* ** * **** **** * *** *** * *** *
    }
* ****** **** * * ** * * **
* * * * * * ** * ** ** * ****** **** ** * * * * * *******
    else
********* * * * ** * * * * *** * * *** ** ****** * * * * * *
** *** * ** * * * * * * 0;
}
answered by (100 points)
edited by
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: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
-----------Re-judge-----------
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:36:21: error: expected expression before ')' token
         printf("no",);
                     ^
0 0
prog.c: In function 'main':
prog.c:31:21: error: expected expression before ')' token
         printf("no",);
                     ^
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:7:17: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     printf("%d",strlen(arr));
                 ^~~~~~
prog.c:7:17: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:7:17: note: include '<string.h>' or provide a declaration of 'strlen'
prog.c:7:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
     printf("%d",strlen(arr));
              ^
0 0
prog.c: In function 'main':
prog.c:8:16: warning: format '%d' expects argument of type 'int', but argument 2 has type 'size_t {aka long unsigned int}' [-Wformat=]
     printf("!!%d!!",strlen(arr));
                ^
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: 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 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
* ** **** * * *** ** * n;
   n>0  &&  n <= 9^1000;
* ** *** *** * * * **** *** ** * *** * *****
   
** * * * ** * * ** * ****** * ** * * ** ****** % 11 == 0)
* ****** ** * *** * ** * ** *** * **** *** * ** * *** ** * * ** **
** * ** * **** *** * * *** * *** ** * *
* * * * ** * * * ** * *** * **** **** ** *** ***** **** ****
*** * * ** * ** *** **** ** ** ** *
* * * ** ** * * ***** * * *** * **** ** * * 0;
**** * * ** ** ** * ** * ***
* * ** ** *** ** **** * *** * ***** *
answered by (190 points)
edited by
0 0
prog.c: In function 'main':
prog.c:6:11: warning: missing terminating " character
     scanf("%d/n,&n);
           ^
prog.c:6:11: error: missing terminating " character
     scanf("%d/n,&n);
           ^~~~~~~~~~
prog.c:7:5: error: expected expression before '{' token
     {
     ^
prog.c:15:1: error: expected ';' before '}' token
 }
 ^
0 0
prog.c: In function 'main':
prog.c:14:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system ("pause");
     ^~~~~~
0 0
prog.c: In function 'main':
prog.c:14: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
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
    int n;
  
*** * ** * ** ** ** * * ** ** * *** ** * * **
   
*** * ** ** ** * * * ** ** * **** * * * **** **** **
* *** * * * **** **** *** * * ** ****** * *** * * * * *** * *
* * * **** *** ** ** **** ** ******* * *** *
** **** * *** ** * * ****** ** * *** ***** * ***** *
***** *** * * * * ** *** * * ** * ***
** ** *** * ** * * *** *** ** *** *** *
* ** * ** ** ** ** * ** ** * **
* * * *** ** **** * * * ******* * **** ** * 0;
* **** *** ** ******* ****** * * * **
answered by (160 points)
edited by
0 1
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main ()
{
** ** * ** * ** * N;
* ** **** * *** ** ** * ** * ** * * *

* * * * * ** ***** * *
*** *** * ** * * *** * *** * *
* *** * *** * * *
** * *** *** ****** * ***** ** ****** * *
** **** ** **** *
* * ** * * * **** * 0;
}
answered by (215 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
prog.c: In function 'main':
prog.c:9:15: warning: integer constant is too large for its type
     else if(N=11111111111111111111111111111111111111111111111111)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:9:15: warning: overflow in implicit constant conversion [-Woverflow]
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main()
int number;
{
* *** ** *** * ** * * ** ** *** * ** ** * **
* * * ***** *** *** **** ** * * * * *** *** ***
* * * * *** ** * * ** * *
*** ** **** * *** ** * ******** * ** *
* * *** ** *** * *
* **** ** ** * ** * **** * **** *** *

* * * * * * ** * * 0;
}
answered by (162 points)
0 0
prog.c: In function 'main':
prog.c:4:5: error: declaration for parameter 'number' but no such parameter
 int number;
     ^~~~~~
prog.c:7:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d",number);
             ^
prog.c:8:8: error: 'n' undeclared (first use in this function)
     if(n%11==0)
        ^
prog.c:8:8: note: each undeclared identifier is reported only once for each function it appears in
0 0
prog.c: In function 'main':
prog.c:4:5: error: declaration for parameter 'number' but no such parameter
 int number;
     ^~~~~~
prog.c:7:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d",number);
             ^
prog.c:8:8: error: 'n' undeclared (first use in this function)
     if(n%11==0)
        ^
prog.c:8:8: note: each undeclared identifier is reported only once for each function it appears in
0 like 0 dislike
Hidden content!
#include<stdio.h>
using namespace std;

int main()
{
    int num;
    printf("輸入N數,判斷是否為11的倍數: ");
    scanf("%d",&num);
    
    if(num/11*11==num)
    {
** ** * *** **** ** *** * *** ** **** ** ***** * *** **** ** * ** ** *** ** *** ** * ** ** * ** ** * ** * * * **** * yes\n" ,num);
*** * * ** * * **** * *** * *** ** ** * *** ******** ** ** ** * ** * * **** * ** * * * * **
** ** **** ***** * ****** ** *** * * * * * * * * **** *** ** * ** * * **** * *** * *** *** *** *** **
*** *** ***** *** *** *** * * ** ** * * ** * * **** ******** * ** *** **** ****** *** * *** ** * * **** * ** * *
**** ** ** * * ** * ** ** ** ** **** ** * ** ***** **** ** ** **** ** * *** * * * * * ** * * ** * * *** **** ***** * *** *** ** *** * no\"num);
**** * *** ******** * * ** * ***** * * * * * ** **** * *** * *** * * ** *** ** ** **** *** * **** ** * * * * * ** **
****** * ** ** * * * * * * *** **** * * ** * ** *** * ***** ** **** * * ** *** * * * * * *** * ** **** ** * ** * ** 0;
}

* ** * ** ******* ** * ** *** * ** * **** * ****** * * **** * ** ** ** ** * ****** * *** * * ***** * * * *** * ** * ** * *** * * *** ** *** * **** ** **** * * *
* * ***** * * * ****** * * *** ***** ** * * ** * * ** ** * *** ** * **** ** * ****** * * ** **** * ** * ** * * * ** * **** * * * ** *** * ** *** * * ** *** * ** * * * ***
** ** * * *** ** ** ** * *** * ** ** **** ** *** * *** * * * * *** **** *** * * * ****** * * ** **** ** ** * ** * ** * * *** * *** * ** * ***** ** * * * *
電機一410623057林献騰
answered by (150 points)
0 0
Show more...
0 0
Show more...
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
********* *** ** * ** * i;
****** * ** * ** * * *** ** ** * **** ** *
** * * * * ** * * * *
* *** ****** * * ******** ** ** * * * ***
* **** * * * * * * * ** **
* **** * * * ****** * * **** *** * **** ****** **
**** **** * * * *** ***
    
* **** ** * *** *** * * 0;
}
answered by (228 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.126.169
©2016-2025

Related questions

2 like 0 dislike
6 answers
[Normal] Coding (C) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38154 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
2 like 0 dislike
8 answers
[Normal] Coding (C) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38155 - Available when: Unlimited - Due to: Unlimited
| 1.8k views
2 like 0 dislike
5 answers
[Normal] Essay (Open question) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38147 - Available when: Unlimited - Due to: Unlimited
| 684 views
12,783 questions
183,442 answers
172,219 comments
4,824 users