3 like 0 dislike
2.7k views

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

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

 

輸入說明:

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

 

輸出說明:

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

 

輸入範例:
 

11111111111111111111111111111111111111111111111111



 

輸出範例:

 

YES
[Exam] asked in 2017-1 程式設計(一)AD by (30k points)
ID: 38939 - Available when: 2017-12-23 09:00 - Due to: 2017-12-23 12:10
| 2.7k views

16 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
* ** ** * ** ** arr[1000];
****** * * *** ** *** * even=0,odd=0,i,n,sum;
    
** ** *** ***** * ** * *** * * * *** ** * *
    
* ** * * * * * * * ********** *
* * ****** * ** *** **
******* * ** ** * * *** * * * * *** *
    {
** ** ** * * * * * ** * *** * * *** ********* * * * * * * * * ** * * ** * ** * * * * * *** * **** *
**** * ** * * **** * ** * *** ** * * ** *** *** * ** ** * * * ** * * * ** * * **** * ***** * ** * * ** ****
* ***** * ** *** * ** ** * * **** ** *** * * * * * * *** * ** **** * ** * * * * * *** ** ** * * * *
* * ** * **** ******** ** * ** ** * ** ** ** **** * *** * ** **** * *** *** ** ******* * ** ** * * ** ** * * * *
    }
    
**** **** * * * ** ***** ** **
* ** * * ***** ******* ** ** * *
*** *** * **** * * * ** * * ***
** *** * ******* ** * *** * *
*** *** ** *** * *** * ** * ** ***
    
* * * * **** *** *** 0;
}
answered by (215 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
Case 6: Correct output
Case 7: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
** * * * ** **** ** num[1000]={0};
    int k, even, odd, i, j;
** * * * * *** * * * ** ** * ** * **
* **** ** * * ****
* **** * **** * *** *** **
**** * * * **** *** * * * ** * * ** * * * * * ** **** *
** * * ** ** * * * * ** **** * **
*** ** ** ** * *** * * **** * * ** *
* ** * * ***** ** * ** ***** * * * * * *
*** *** ** **** * * * * * *****
** ** *** ** * * ** *** ****** ** **
***** *** * * * * * * ** **
*** * ** ** *** * * * * * * **   
* ** * **** * * ** * 0;
}
answered by (144 points)
edited by
0 0
prog.c: In function 'main':
prog.c:5:23: error: expected expression before ']' token
     scanf("%d",&array[]);
                       ^
prog.c:7:5: error: 'returm' undeclared (first use in this function)
     returm 0;
     ^~~~~~
prog.c:7:5: note: each undeclared identifier is reported only once for each function it appears in
prog.c:7:12: error: expected ';' before numeric constant
     returm 0;
            ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{
    char c[1000];
** * * * ** * * * ** ** * * **
    int a,i,x=0,y=0,z;
* * *** * **** *
**** ** * **** * * * ** * ** * * *
    {
* ** * * * * * ********* * ** ** ** * *
* *** * * * ** * ** ***** ** ** * * *
* * *** * ** * ** ***** ** ** * * * ** ** * ***** * *** ****** *
* ***** ** * * * *** * * * ** *** * ** *** * * * ** * *****
* ** *** ** * ** ****** * * * *** ***** *** *
** *** * **** ** ** *** * * ** ** ***
* ** * * ** **** * **** * * * * *** * *** ** * ** *
* ** ** * *** ** ********* ** * * **** ***** * *** * * *** ** *** **** * *
* ****** * * *** * * ** * * * ** ** * ***** ** ******** ** *** *
** ****** * * ** * *** ** *** * **** **
    }
**** **** * * ** * * * ** ** **
* * ***** ** * * * ** * ** * ** *** **** * ** * ***** *** * **
    else
* * ** ** * * * * ** * * * ** * ** *** **** ** * **
}
answered by (100 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
Case 6: Correct output
Case 7: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
int main ()
{
** * * *** * *** ** str[1000]={0};
*** ** * * * **** ** j , n,sum1=0,sum2=0;
* *** * * * * *** * * ** * **
* **** *** * ******* **** *** = strlen(str);
** *** **** *** * **** = 0;j < n;j++)
** * *** * * **
**** ** * * * ** *** ** ** ** * * * *** *** ** ** ** * **** * == 0||j%2 == 0)
*** ** ** *** *** ** * *** * ** *** * * * * ** * ** ** * = sum2 + str[j] -48;
*** ***** * * * * * * * ** * *** * * * * * * *** ** * * * if ( j%2 != 0 )
* ***** *** * *** * * * ** ** ****** ***** * * * ** = sum1 + str[j] -48;
* **** ** *** * ** * *
* * * ** *** ** * ***** * (sum1 > sum2)
***** *** **** **** * * * *
* *** * *** * * *** * * ** ****** * ** - sum2) % 11 == 0 )
* * * *** * * ***** *** ****** ** ** * * \n");
* * * ** *** *** * ** **** * * ** ** * ***
* ** * * * * * *** * ** **** ** *** *** * * * *** * \n");
** * * *** * * * * *
**** **** *** ** if(sum1 < sum2)
** * *** ** * * * *
* * * *** * * ** * ****** ** * - sum1) % 11 == 0 )
** * *** * * *** * ** ***** ** * ** ****** * \n");
*** ** * * * * * * ** * *** * ** ** * *
*** * * * * ** ** * * ** * * ** *** * *** * * * **** \n");
** * ******* * * ** *
*** **** ** ** * ****** * * if (sum1 == sum2)
* *** * * ** * *** ** * ** * ** * *** * ** * \n");
*** * * **** ** **** * * * * ** * *
* * * * *** * * ** * * 0;
}
answered by (209 points)
edited by
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",&str);
             ^
prog.c:21:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system ("pause");
     ^~~~~~
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",&str);
             ^
0 0
prog.c: In function 'main':
prog.c:7:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(str);
     ^~~~
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/ccwAQ4Bd.o: In function `main':
prog.c:(.text+0x3c): 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
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
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",&str);
             ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
Case 6: Wrong output
Case 7: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
* *** ** * * ** *** * * arr[1000];
* * * ***** even=0,odd=0,i,n,sum=0;
   
* ** ** ******* ** * * * *** ** **
   
*** * * * **** ** ** ** *** ** *
* ***** * * ** * *
   
** * ***** *** * *** * ** ***
* ** * * *** * *****
** * *** * *** ** *** ** ** * *** ** **
** *** ** * * *** ** * *** * * ** *** * *** * * ** ** * ** **
*** * ** * * ** ** ****** * * ** if(i%2!=0)
** * * ** * * ** * * * ** * ** * * * *** * * **** * * ***** * ** * * * * ** * * * * ** *** * * * ** ** *** * *****
** **** * * * ***    
* ** * * * * * ** *** *
   
** *** * * *
** *** ******
* *** ***** ****** ** ** **** * ** * *** * * * * ** ** * **** * * * **** *** * **** * **
***** ** * ***** *
* ******** ** * * ** if(sum%11!=0)
* **** ******* **
** * *** * **** * * * * * * * * *** ********* *** ** * *** ****
*** *** *******
   
  
* ** **** * * * * ** * * *
** * * * ** * **
}
answered by (174 points)
0 0
prog.c: In function 'main':
prog.c:8:12: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int *' [-Wformat=]
    scanf("%s",arr);
            ^
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
Case 6: Correct output
Case 7: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main(){
* * * * ** ** * ** ** one=0,two=0,i,ans;
*** *** * * * * ** * ch[1000];
* ** *** **** ***** * * * * *** * * *
    
* *** *** ** **** * * * ******** **
*** ** * ** ********** *** * ** ** ***
***** * ** ** ***** * ****** * ** * * **** **** * * * *** *
* * ** *** * ** * * * *** * ****
* * **** **** * *** * * ** * * ** * ***** *
** ** ** * * * ** ***** * * *** *** ** * * * ****** **
*** * **** ** * ****** * ** ** ** * * **
    }
    
* * ** * * * *** * * * ** *
    
* ** * * * * * * * ** * * *
**** ** * ** ** ** * **** ** ** * * * * ** *
* * *** ** * * ****
* * * ** * ***** **** **** * * *** **
}
answered by (192 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
Case 6: Correct output
Case 7: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.58.6
©2016-2024

Related questions

2 like 0 dislike
5 answers
[Exam] asked Dec 23, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38942 - Available when: 2017-12-23 09:00 - Due to: 2017-12-23 12:10
| 833 views
2 like 0 dislike
18 answers
[Exam] asked Dec 23, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38941 - Available when: 2017-12-23 09:00 - Due to: 2017-12-23 12:10
| 2.2k views
4 like 0 dislike
16 answers
[Exam] asked Dec 23, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38940 - Available when: 2017-12-23 09:00 - Due to: 2017-12-23 12:10
| 3.9k views
3 like 0 dislike
12 answers
[Exam] asked Dec 23, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38938 - Available when: 2017-12-23 09:00 - Due to: 2017-12-23 12:10
| 1.9k views
2 like 0 dislike
3 answers
[Normal] Coding (C) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38168 - Available when: Unlimited - Due to: Unlimited
| 469 views
12,783 questions
183,443 answers
172,219 comments
4,824 users