2 like 0 dislike
1.6k views
Show more...
[Normal] Coding (C) - asked in 2017-1 程式設計(一)AD by (30k points)
ID: 38162 - Available when: Unlimited - Due to: Unlimited
| 1.6k views

6 Answers

0 like 0 dislike
Hidden content!
* **** ** *

int main()
{
* * ** int n;
* ** * * * int j, k, i;
** *** * *** int count;
* ** * * * int * *** * *
* * * ** * int flag, a, temp;

*** * * * * * * * * ** * **** ** ****
*** * *** ** ** for(j = 0;j ** ** n;j ++)
* * * * * * {
* ** * ** * * * * * * a = 0;
***** ** **** * ***** * * ** *** ***** * * * *** **
** ** ** * ** * * for(k =0 ;k < count;k ++)
** ** * * ** * ** {
* ** *** * * * * * * ** ** * * ** * ****** * * * *** ** * **
* * * * * **** * }
** **** * *** ** ***** flag = 1;
** * * * ** * ** * * **** ** *
*** *** ** ** *** * {
*** ** **** * * * ** * * * ** flag = 0;
* * * * *** * *** * * * * * ** for(k = 0;k ** count - 1;k ++)
*** * * ****** * *** * **** * * ** * * * {
* ** * * * ** *** *** ** *** ** ** * * if(c[k] * * * c[k + 1])
** * * * ** ** * * * * * * * ** * ** *** ** * ** ** {
*** *** *** * ** ** ** * * * * ** * * * * * * flag = 1;
*** * * * *** * * * * * * * *** * **** ** * * * temp = c[k];
****** *** * * * *** **** ** * * **** * * * * ** **** c[k] = c[k + 1];
*** * *** **** * * ** * ***** *** * ** * * **** * * * * ** * c[k + 1] = temp;
*** * ** * * **** * * * * *** ** **** ** * * ***** a ++;
* * ** * * * * ** * **** *** * * ** * *** }
* * * * * * ** * ** * * ** ** *** }
* * * ** * *** * * * }
*** ** *** ** * ***
* ** ** * * * ** * s[j]=a;
* * * * **** }
*** ***** **** * * ** train takes %d * ** * s[0]);
*** *** * * * * ** **
** * *** {
* * ** * *** * *** *** * * ***
*** ** **** ** * ** ** * * * * ** * train swapping takes %d ** *** * s[j]);
** * * * ** ** * **** *** **** ****
* * * * **
* * * ** return 0;
}
answered by (160 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
void swap(int a,int b)
{
    int t=a;
    a=b;
    b=t;
}
int main()
{
    int n,num;
    int i,j,k;
* * * *** * * * * *** *** * * ** * *
    for(i=0;i<n;i++)
    {
** ** * ** * * **** * ****** * ** * *** * * ** ******* * * * ** * **
**** * * * ** * ** **** ** ** **** ** ** * train[num],times=0;
*** **** * * * * ***** *** * * ** * * ** * * *****
** * * * *** ** **** *** ** ** ** *** * * ** *
**** * * ** ** * ** **** *** * ** * ** * * * * * ** * ** * * ****** * * ** ** ** * ****** *
** * * *** * ***** ** *** **** * * * * * * ** *** *
* ** * ** * **** * * ******** * *** ** * * ** *** *
** ** **** * * ** ** * ** * * * ***** ****
** *** **** * *** * * ** ** ** ** ** * * * *** * ** ** ** * * * * ***** * * ** **
* * * ** *** * *** ** * * * ****** * * *** ********* *********
** * ****** * * **** * * **** * * * * * ** *** * ** *** ** * ** * ** ** ** **** * * ** * * * ** * ** ****
* ** * * *** * * * * * * * * * ******* * *** * * **** **** ** ** * ** * *
**** * * * * ** * * ** *** * **** ** * * * ** *** ****** * * * * **** * * * ** * **** ******** * * **** * *
* **** * *** ** * * **** * * * *** *** * ** *** * **** ** * * *** **** **** ** ****** * *** **** * *
*** * ***** **** *** * ** * * **** * * *** * * * * ** ** ** **** * * *** **** * * **
* *** * * * * ***** *** ** ** * ** *** * * * * **** * ** ** * * * *
* *** * * ** * * * * ** ** *** * ** **
* * ** *** * ** * * * ** ** ** * **** * * * *
* * * * ** ** * * ****** * *** * * * ***** ** * * * ** * *** ** ** *** * train swapping takes %d swaps.",times);
**** *** * ** * * ** * **** ** ***** *
* ** ** * ** **** **** * * * * * * * ** * *** *** *** ** ** ** ** *** * ** train swapping takes %d swaps.\n",times);
    }
    return 0;
}
answered
edited by
0 0
prog.c: In function 'main':
prog.c:16:10: error: 'true' undeclared (first use in this function)
   flag = true;
          ^~~~
prog.c:16:10: note: each undeclared identifier is reported only once for each function it appears in
prog.c:19:11: error: 'false' undeclared (first use in this function)
    flag = false;
           ^~~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
* * ** * ** * *

int main(){
*** *** * ** int ** **** *
* *** *  
  * ** * * ** * * **** *
**** * ** * *
***** ** * * **** ** **
* ** ** ** * * *** *** times=0;
**** * ***   ** ** ** * ** ***** * * *******
* * ** * ** *** **** int arr[num];
** * * **** * * ***
* ** ** * ** * * * *** * * * * ** **
* * **** * * ** ****** * **** * * ** * * * * ***** * * * * * **
* * **     }
*** *       *** * ***
* ***           * ** * *
* * ** * **     * *** ** *** ** *** *
**** * * * * ** * ** * ** * ** ** ** * * **** s=arr[i];
* * ** * *** ** ** ** ** * * * ** * * * * ** ******
*** ** * **** ** ** *** ** * ****** * * ** * arr[j]=s;
* * ** * ** *** * * *** * *** * * ** * ** ** times++;
* * * * * ** * * * ** * * }
* ** ****** * ** * * * ** * * *
* * * * * ** ** }
*** * ** ** **** ** ***
* * * * *** * * ** * * * * * *** * * ** * * ****** ** *** ** * train swapping takes %d * * *** ***
*** * * * ***** * ** * * * ** * ** * ** **
* * * * * * * *** ** ** * *** * ** ******* * * ****** * * ***** ***** * * train swapping takes %d *** * *** **
**** ** ** ** *** * *** * * ** ** * * *** train swapping takes %d * *** * *** ** **
* *** ** }
}
answered by (192 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int n,num;
    int i,j,k,temp;
* * *** * ** ** **** * ******* * *** *** *
    for(i=0;i<n;i++)
    {
* *** * ** ** ** * ** **** ** * * * * **** ******* *
** * * ** *** * ** **** * *** * train[num],times=0;
* ** * * *** * * * * ** ** ** ** * ** * * * * * * **
        {
* * * **** * ** *** **** * * ** ******* ***** ** ** * * ** ** * * * * **** * **
        }
* * ***** * * * ***** ****** * * * * ** *** * ** ** *
* * * *** *** * * *** * * *** ** * ** **
** * * * * * **** ** * *** * * ** ** * * *** ** * *** * * * * ** **** ****
*** * ** * * ***** ** **** * ***** ** ** * * **** *** * * ** ** *** ** **
* * *** * * * * *** ** * *** ** * **** **** * * * * ***** ** ** * * **** * * * * **** ** *** *** ******
* * *** **** * *** **** * ** * * ** * ** ** * *** * ** * ** * ****** ** **** ********** *   temp=train[j];
** **** * ** *** ** * * **** * ** ** *** ** * * **** * *** * * * * ** *** * * **** * *
* ** * ** **** * ***** *** * * *** **** * ***** ** *** ** * ** * ***** ** ** * * * * *** ** * * ** * * *
* * * ** ***** **** * ** * * ** **** ** * ***** * *** * *** *** ******** * * ** ***
* * * *** ** ** ** *** ** ** **** * * * ** * * * * ** ** * ** *** ** * * ***** **** ** ** *** * * * * *** * * ** *
****** ** ***** ** **** ** *** ** * * *** *** * * * * ******* * *** ** ** * * * * * **
** ****** *** * *** * ** *** ** **** **** ***** * * * * * **** * * *
** * *** * * * ****** * * * * ******* **** *** ** ** **
** **** * *** * * ** * ** ***** ** * **** *
* ***** * * *** * ** * ****** * ** * *** * ** * * * * ** ** * * ** * train swapping takes %d swaps.",times);
* ** * * * * *** * *** ** *** * ****
*** **** * ***** ** ***** *** * *** **** * ** * ** * * * *** *** ** ******* ** ** train swapping takes %d swaps.\n",times);
    }
    return 0;
}
answered by (174 points)
edited by
0 0
Case 0: Correct output
Case 1: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
* ** * * * ******* *
int main()
{
* *** * * * int n, c, swap, temp, flag;
* * * * *** int j, k;
* * int * **
**** * * ** *** *** * ***** * * *
** * ** for(j = 0;j < n;j++)
*** {
*** * * * ** * swap = 0;
** *** * * ** **** * * ******* * * ** *
** * * ** * *** * * **** for(k = 0;k < c;k ++)
******* ** **** ** *** ** *** * * ** ***
* ** * ** * * flag = 1;
** * * ** * ** ** * *** * ==1)
** ** * * ** * ** * * {
***** * ***** * * ** * * * * * flag = 0;
* ** * ** ** * * ** * ** ** for(k = 0;k < c -1;k ++)
* *** **** * * * * * * ** *** ** * {
** * ** * * **** ***** * * ** ** * * ** ****** > * * *
*** * * ** *** * *** ** * * * *** * *** ** {
*** * ** ** * *** **** * * * *** * * * ** * * ** ** * * flag = 1;
* * * * ** * ***** ** ** * *** ** * ** ** * **** * * * * * temp = ** ***
** *** * *** * * *** * * * ** * * * * **** ** * * array[k] = ** *
* ** * *** * * ** * * * * * *** ** * ** ** * * = temp;
* * * * * * ****** * ** ******* * *** * ** *** ** swap++;
* * ** * ** * * * **** * *** *** * }
* * * *** * * ** * **** * ** * }
** * *** * *** * *** }
** ****** * * * * *** ***** **** * train swapping takes %d ******** * *****
* ** ** }
** * * * * * return 0;
**** **
answered by (190 points)
edited by
0 0
prog.c: In function 'main':
prog.c:19:10: error: 'true' undeclared (first use in this function)
   flag = true;
          ^~~~
prog.c:19:10: note: each undeclared identifier is reported only once for each function it appears in
prog.c:22:11: error: 'false' undeclared (first use in this function)
    flag = false;
           ^~~~~
0 0
prog.c: In function 'main':
prog.c:19:10: error: 'true' undeclared (first use in this function)
   flag = true;
          ^~~~
prog.c:19:10: note: each undeclared identifier is reported only once for each function it appears in
prog.c:22:11: error: 'false' undeclared (first use in this function)
    flag = false;
           ^~~~~
0 0
prog.c: In function 'main':
prog.c:19:10: error: 'true' undeclared (first use in this function)
   flag = true;
          ^~~~
prog.c:19:10: note: each undeclared identifier is reported only once for each function it appears in
prog.c:22:11: error: 'false' undeclared (first use in this function)
    flag = false;
           ^~~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
void swap(int a,int b)
{
    int t=a;
    a=b;
    b=t;
}
int main()
{
    int n,num;
    int i,j,k;
* ** ** *** ** * **** * ** ** ** * * **
    for(i=0;i<n;i++)
    {
* *** * * * * * *** **** * * * *** * * * ***** * *
***** * * ** * * ** * * * *** * * ** * **** * train[num],times=0;
** ** *** * * * * *** ***** ** * ** *** ** ** ** * *** * * *
** *** ** * * * * * ** ** **** ** * * * *
**** ** * *** * ** * ** ** * **** * * * ** * ** *** **** * * **** * ** * * * * * *
* ***** ****** * * *** ** * ** ***** *
*** * *** *** ** * * ** *** ** *** ** * * * * ** * ****
* * * * *** ** * * *** * ** * ** * *
***** * ** **** * * ** **** ** * * **** * *** ******* ** ***** * * * ***
**** * ***** * ** * * * * ** * ** ** * * * **
*** * * * **** *** **** *** ** ***** ** ** * ** *** * * * ** * * * ***** * **** ** ***** * **
* *** * * ****** ** ** * * * ** * ***** * * ** ** ** * ****** * * * * *
* * ****** * ** ** ** **** ** ** * ** ** **** * * * ** ***** * * * ** * * * ****** * * *** ** **** ** * * *
* * ****** *** *** * * * * *** * ** * * ***** * * ** **** ***** ** * * *** * * ** * * ******
** * * ** * *** * * * * ** * * ** *** ** * ****** * * **** * *** * *** *** *** ** *
**** **** ** * * *** ** * * * * ******* * ** ** * *** *** * ** * *** *
** * * **** ** * * * * *** ***** **
** *** * * * * * ** * ** ** * * *****
**** ** *** * ****** ** ** ** ** * * * ** ** ** * ** * ** ***** train swapping takes %d swaps.",times);
** **** *** ** *** * * * * ****** ** ***** *** ** *
* * * ***** **** *** ** *** * *** * * * ** ** * * ***** * * * ***** train swapping takes %d swaps.\n",times);
    }
    return 0;
}
answered by (30k points)
0 0
Case 0: Correct output
Case 1: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.59.22
©2016-2025

Related questions

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
| 996 views
2 like 0 dislike
5 answers
[Normal] Coding (C) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38165 - Available when: Unlimited - Due to: Unlimited
| 1.6k views
2 like 0 dislike
7 answers
[Normal] Coding (C) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38159 - Available when: Unlimited - Due to: Unlimited
| 1.5k views
2 like 0 dislike
3 answers
[Normal] Essay (Open question) - asked Dec 20, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38158 - Available when: Unlimited - Due to: Unlimited
| 704 views
12,783 questions
183,442 answers
172,219 comments
4,824 users