8 喜歡 0 不喜歡
6.9k 瀏覽
若一個正整數的奇數位數字和與偶數位數字和兩者差的絕對值是11的倍數,則這個正整數就是11的倍數,否則就不是11的倍數。

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

 

輸入說明:

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

 

輸出說明:

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

 

輸入範例:

11111111111111111111111111111111111111111111111111

 

輸出範例:

YES
[考試] 最新提問 分類:2017-1 程式設計(一)AD | 用戶: (18k 分)
ID: 36178 - 從幾時開始: 2017-12-08 18:30 - 到幾時結束: 無限制
| 6.9k 瀏覽

19 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
* ****** *** * ** ** *** * *** * i;
* * * * *** ***** * * **** *** a,b;
     int N[1000];
    
     scanf("%s", N);
     
* * ** * * * * * * ** *** * (i=0; i<=1000; i=i+2)
     {
* ** * * ** ** ** ** * *** * * *** * * ** *
* * * * * * *** ** * * **** *** * = a+N[i]; ******** * *** * ** * ***** **** ***** *
     }
     
* * *** * * * * ** ** * ** * (i=1; i<=1000; i=i+2)
** * **** **** ** * * ** * *
* *** *** **** *** * ** *** ** * * *** ***** * * ** = b+N[i];
     }
     
***** * *** * *** * * ** * (a>b)
     {
* ** * ** * * ** * * *** * ******** * *** * * ** **** ((a-b)%11==0)
* **** * * * * * * ***** ** * ** ** **** ***
** **** * * * ** ** * * *** * * * ** ** * ** * ** * **** *** *******
*** ** **** * * * * **** ** * ** ***** *
** * *** * * * * *** ** *** ***** * * ** * ** ** **
***** *** ** *** ** ****** *** *** ** ** ** ***
* *** *** ** *** * * ** * * **** *** * * **** * * *** * ** * * * * * **
* ****** ** * * *** **** * ***** * ** ** *
* ** * ** * ** *** ** * ****** *
*** * * * * *** ** * ***** if (a<b)
     {
* ** *** * *** * ** * * ** * * * * * * ((b-a)%11==0)
** **** * *** * * * ***** ** ** ******* *** ***** *** *
** * * ** * * * ** *** * * * * * * * **** ** *** * * * * ** ** **
*** * ** * ** * * *** ******* * ** *** * * **
** ** * * * * * * * * * * ** * ** * * ** * **
* * ** * * * ** * *** ** * **** * ***** *
******* * * *** ** * * *** ** * * ** *** **** * * * *** *** ** * *
* *** **** ** *** ** * * * ********* * * ****** *
****** ** * * * * *** * *** *
*** * * * *** * *** ** * ******* if (a=b)
** * * * ***** *** ** * ****** * *
*** ************ *** *** * ** * ***** *** * * * *** * ** * ** **** * * **** **** * *
******* **** * ** *** ** **
** * * ** * ** * * * * * * * *
* * * ***** * ***** ** ** * ** * ** ***** ** *
*** * **** ** * ** *** **** *** ** *** 0;
* * *** ** **** * *** **** * ** *
}
******** ** * **** * * ** * * * * **** * *** * **
最新回答 用戶: (202 分)
0 0
prog.c: In function 'main':
prog.c:8:11: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int *' [-Wformat=]
   scanf("%s", N);
           ^
prog.c:48:7: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
       system("pause");
       ^~~~~~
0 0
prog.c: In function 'main':
prog.c:8:11: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int *' [-Wformat=]
   scanf("%s", N);
           ^
prog.c:48:7: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
       system("pause");
       ^~~~~~
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

int main()
{
* ** ** **** * ** ** long long n;
* ** ** * *** * *** * *** ***** ** **** * * ** * *
    {
* * **** ** *** *** * * *** * * * * *** **** * *** *
* * **** * * * ** ***** * ***** ** ** * ** * * *** * * * **
**** * * *** ** * **

* ***** * ***** ***** 0;
}
最新回答 用戶: (114 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
** *** *** * * * input[10000];
* * * * ** * * * ** * * ** * ** * * ** * *** **** *
    {
** * * ** *** * * ** * ** ******* ***** i,l=strlen(input),a=0,b=0;
** * * **** * * * * * * * ** ** ***** * * * * *
* * ** * * *** * * *** ** * ****** ** * ***** ***** ** *
** * ** ** * * ** * ***** ** * *** ** ** * * * **** *
*** ** *** ***** * ***** * * * * **** * ** ** * ** * * *
* **** ** ***** * ** * ** ** *** **** * ** * ** *
** *** ** ** ** ** **** * **** * * * ** ** * * ** * *** * ** * * ** * **
** **** * ****** *** ** *** * * **** *
* * * **** * ** *** * * * ** **** * * ** *** *** * *** *** *** * * * *
    }
** * *** *** * * * ** ** 0;
}
最新回答 用戶: (30k 分)
修改於 用戶:
0 0
prog.c: In function 'main':
prog.c:7:19: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[10000]' [-Wformat=]
     while(scanf("%s",&input)!=EOF)
                   ^
prog.c:14:12: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
         if(abs(a-b)%11==0)
            ^~~
0 0
prog.c: In function 'main':
prog.c:14:12: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
         if(abs(a-b)%11==0)
            ^~~
0 0
prog.c: In function 'main':
prog.c:14:12: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
        ans=abs(a-b);
            ^~~
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
prog.c: In function 'main':
prog.c:13:12: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
         if(abs(a-b)%11==0)
            ^~~
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
#include <string.h>
int main()
{
* ** * * *** * * * **** i,j,add=0,even=0;
** * * ** * * ** *** *** * ** a[1000]={0};
**** ******** * ***** ** * * ** * * ** *






* * * *** * ** * *** ******* *
    {
** * * * * * ** * * * ***** ******* * *** * * ** *
* * *** *** * * * ** *** ** *** * ** ** **** **
* * * ** **** ** * * * * **** *

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

* * * *** ******* * **** * * ** ** **
    {
** **** **** **** * ** *** * * ** * * ** * ** )
** ** * *** ** ** * * * * ** * * *
*** * ** ** *** **** * ** * * *** ****

    }

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

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

* * ***** *** ** * * * if((add-even)%11==0)
*** * * * ** * ** *** * **** ** *** *** ** * *** *
** ******* * ** * * ***** *
* * ****** * ** ** ** * * *** ** * ** * ******* ** ** * * *


** * * * * ** ****** 0;
}
最新回答 用戶: (174 分)
修改於 用戶:
0 0
prog.c: In function 'main':
prog.c:10:13: error: 'i' undeclared (first use in this function)
     for(n=0;i=0;i<=a;i++) //\xe5\xa5\x87\xe4\xbd\x8d\xe6\x95\xb8\xe5\x81\xb6\xe4\xbd\x8d\xe6\x95\xb8\xe5\x88\xa4\xe6\x96\xb7,a<=10^999
             ^
prog.c:10:13: note: each undeclared identifier is reported only once for each function it appears in
prog.c:10:21: error: expected ')' before ';' token
     for(n=0;i=0;i<=a;i++) //\xe5\xa5\x87\xe4\xbd\x8d\xe6\x95\xb8\xe5\x81\xb6\xe4\xbd\x8d\xe6\x95\xb8\xe5\x88\xa4\xe6\x96\xb7,a<=10^999
                     ^
prog.c:12:18: error: invalid suffix "n" on integer constant
       if(c=a/10^(2n))
                  ^~
prog.c:17:22: error: expected ')' before ';' token
      for(n=0;i=0;i<=a;i++)
                      ^
prog.c:19:38: error: invalid suffix "n" on integer constant
                           if(d=a/10^(2n+1)
                                      ^~
prog.c:20:27: error: expected ')' before 'even'
                           even+=d;
                           ^~~~
prog.c:21:5: error: expected expression before '}' token
     }
     ^
prog.c:25:1: error: expected '}' before 'else'
 else
 ^~~~
prog.c: At top level:
prog.c:28:2: error: expected identifier or '(' before 'return'
  return 0;
  ^~~~~~
prog.c:29:1: error: expected identifier or '(' before '}' token
 }
 ^
0 0
prog.c: In function 'main':
prog.c:6:12: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     printf("");
            ^~
prog.c:7:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(a);
     ^~~~
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:14:16: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     for(i=0;i<=strlen(a);i=i+2)
                ^~~~~~
prog.c:14:16: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:14:16: note: include '<string.h>' or provide a declaration of 'strlen'
prog.c:22:17: warning: incompatible implicit declaration of built-in function 'strlen'
      for(i=1;i<=strlen(a);i=i+2)
                 ^~~~~~
prog.c:22:17: note: include '<string.h>' or provide a declaration of 'strlen'
/tmp/ccEDkE9I.o: In function `main':
prog.c:(.text+0x51): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:6:12: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     printf("");
            ^~
prog.c:7:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(a);
     ^~~~
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:14:16: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     for(i=0;i<=strlen(a);i=i+2)
                ^~~~~~
prog.c:14:16: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:14:16: note: include '<string.h>' or provide a declaration of 'strlen'
prog.c:22:17: warning: incompatible implicit declaration of built-in function 'strlen'
      for(i=1;i<=strlen(a);i=i+2)
                 ^~~~~~
prog.c:22:17: note: include '<string.h>' or provide a declaration of 'strlen'
/tmp/ccuq6Kb5.o: In function `main':
prog.c:(.text+0x51): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:6:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[1000]' [-Wformat=]
     scanf("%s",&a);
             ^
prog.c:13:16: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     for(i=0;i<=strlen(a);i=i+2)
                ^~~~~~
prog.c:13:16: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:13:16: note: include '<string.h>' or provide a declaration of 'strlen'
prog.c:21:17: warning: incompatible implicit declaration of built-in function 'strlen'
      for(i=1;i<=strlen(a);i=i+2)
                 ^~~~~~
prog.c:21:17: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
prog.c: In function 'main':
prog.c:7:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[1000]' [-Wformat=]
     scanf("%s",&a);
             ^
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main(void)

{
** * ******* * ** num[1000];
** * * ** * **** *** * i,a,b;
* * *** **** ** *
* ****** ***** *** * * * ** * a number:");
* * ** *** *** * * * = 0; i<1000; i+2)
* * **** * * *** * *
* ** *** * ** * *** *** += num[i];
* * * ** * ****** **** += num[i*2+1];
* * * * * ***** *
***** * * * * * *
** * ****** * * * ** * ** == 0)
* ** * *** * * * ****** ******* * *** **
* * * ** *** * *** * **
* * *** **** * *** * ****
** *** * * *** ** * ****** * * ***** ** *
* * * * * *** ***
*** * ** *** **** * * * 0;
}
最新回答 用戶: (212 分)
0 0
prog.c:1:2: error: invalid preprocessing directive #inlude
 #inlude<stdio.h>
  ^~~~~~
prog.c: In function 'main':
prog.c:8:5: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
     printf("Enter a number:");
     ^~~~~~
prog.c:8:5: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:8:5: note: include '<stdio.h>' or provide a declaration of 'printf'
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 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
* ** ******* ** ***** **** x;
** ** ** * * ** ** ** ***** * enter a number\n");
** * * **** ** *** *** * * * *** * * *
* * ** * ** * ***** * *
* * * *** * ****** ** * ** * * * ***** ******* *** ****** ******
** ** * **** *** ****** * **** *** ** **
************* * * ** *** * ** ** * *** * *** *** * **** * *** * *** *
    
* * * ** * * ** **** *
}
最新回答 用戶: (172 分)
1 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 不喜歡
內容已隱藏
#include<stdio.h>

int main()
{   
*** * * ****** * * ****** * **** a;
* *** * *** ** * ** * ** * *** ** * your number:");
* ***** * ** ** ** * *** ** ** * * * **
** * * * * **** ** * ** % 11 == 0)
** ** *** ** ** * * *** * * * * ** **
** ** * ** * **** ** *
* * *** * *** * * * * * **** ** * ***
* ******** ** * **** *
* * **** ** * * * *** *** * * * *
**** *** * *** ******* * 0;
}
* ** * * ** **** * * ****
最新回答 用戶: (164 分)
0 1
prog.c: In function 'main':
prog.c:13:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>

int main(){
** ** * ***** * *** *
**** * *** * * * num;
***** ** * * ** * * *
*** ** ** * ** ** *** *** **** ** ****** ** *
* *** ** * *
    
* ****** * * ** * * * *
** * ** * *** * *******
** * * * *** ** * * * ** * * * *
** ******* ****** ** * * ** * ** * *

* *** * * ****** **
******* ******** ** * *
}
最新回答 用戶: (192 分)
修改於 用戶:
0 0
prog.c: In function 'main':
prog.c:8:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[1000]' [-Wformat=]
     scanf("%s",&ch);
             ^
0 0
prog.c: In function 'main':
prog.c:8:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[1000]' [-Wformat=]
     scanf("%s",&ch);
             ^
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: Wrong 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:8:13: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[1000]' [-Wformat=]
     scanf("%s",&ch);
             ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
* * *** ** * * ** * in,a;
* ** * ** **** * **** * *** ** * * ** **
* * * ** ** **** *** *
* ** * * * **** ** ** ***
** ** **** ** *** *** *
***** *** ** * ** *
** *** * * ** **** ***** ** * ***** ** **** * * * ** *
** * ** * * ***** * ******* * ******** *** **
* **** * * * ** * ***** **** ** if (a!=0){
* ** **** * ** * * ** * ***** *** * * ** * ** * *** ** ** * * **
* ** * ** ** *** *** ***** * ** ** * ** * * **** * *
*** * ** *** ** *** ***
system("pause");
return 0;

}
最新回答 用戶: (185 分)
0 0
prog.c: In function 'main':
prog.c:6:14: warning: format '%ld' expects argument of type 'long int *', but argument 2 has type 'long int' [-Wformat=]
     scanf("%ld",in);
              ^
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
* ** * ** * *** *** * j, k = 0, l = 0;
** ** * ** ** ** ** * * str[10000] = {0};
*** * * ** ** * * * ** * * * ******* *** str);
* ** * **** ****** * * * = 0;j < strlen(str);j ++)
** ** * * ** * * * *
* *** *** * * * ** * **** * * ** * * **** *** % 2)
***** * *** ** * * * * ** **** ** **
* *** ** ***** ********** * * * * * * ** * ***** **** ** *** * *** * * += str[j] - '0';
*** ** * ** ** * * * * ** * * * * **** *
*** *** ** **** ** * *** * * ** ***** *** *
** * * * * **** * * * * * * **** *
* ** * **** *** * * * ** **** *** * ** * ** ***** ** += str[j] - '0';
** * * * ** * ** * * *** * ** *
** * ** * ** * * * ** * * *
*** *** * * * **** *** * - l) % 11 == 0)
** ** * ** * * * * * * * ** ** ** * * ***** **
* * * *** * ** ** *
* * * ** * ** ** * ** **** * * * ** * * **** ** **
}
最新回答 用戶: (18k 分)
0 0
Case 0: Correct output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
-----------Re-judge-----------
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.69.17.67
©2016-2025

相關問題

2 喜歡 0 不喜歡
6 回答
[正常] Coding (C) - 最新提問 12月 20, 2017 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 38154 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.6k 瀏覽
2 喜歡 0 不喜歡
8 回答
[正常] Coding (C) - 最新提問 12月 20, 2017 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 38155 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2.4k 瀏覽
2 喜歡 0 不喜歡
5 回答
[正常] 開放式問答 - 最新提問 12月 20, 2017 分類:2017-1 程式設計(一)AD | 用戶: 楊修俊 (30k 分)
ID: 38147 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 934 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶