2 like 0 dislike
3.7k views
Show more...
[Exam] asked in 2017-1 程式設計(一)AD by (30k points)
ID: 38941 - Available when: 2017-12-23 09:00 - Due to: 2017-12-23 12:10
| 3.7k views

18 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n,num,i,j,k,times;

****** * * * * * ** ** * * ** ****** ** ***
  
****** * ** ** *** * * * * **** * ** ** * ** *** * * * ******** ** * * * **** ***** * ** ** * * ** ** * * ** ** *** * * *******
   {
* ** ** * ** * *** * ** ** ** * *** * * *** * ** * ****** *******
   }
   
int t[num],temp;
* ** ** * * * * * *
* * * * ** * * * *** ******** **** * *
* *** * * ******* * * * * * **** ** *  for(k=j+1;k<num;k++)
** ** * * *** ** ****** ** * * * ** **** ** * *** **
** ** *** **** * *** * **** *** * ** ******** ** ** ****** * * *** * * ** * ** * * *
* **** * * ** * * * * * * * * **** * * * * * *** *** * ** * * ** * **
** * ** * ** * *** **** ** * ** **** ** * ***** * * * * * ***
* * ** * ** ** * ** ******* * ** * * *** * ***** * * ** * *** * *** *** ** * *
** * ** *** * * *** * **** ***** * **** * ** * ** * * ** ** **** * * ** ** * * *
* *** *** * ** * ** ****** * ** * * * ** * ** ** * * * * * * **** **** **** ****** * **** * * ** * * ** ** * * * * * *** * * * * *** **** * * * *
* ** * * ** **** * ** ** **** *** * *** ** ** * ***** ***** *
**** * * * ** ** * ** ** ** ***** * ***
** ** * ******** * *** ** * ** *** * *** * ** *** ** ** * * ** ** * * *** ** *** ** * * ** **** *** * *** **

    if(n==j-1)
** * * * ** ** * **** *** * * * ** train swapping takes %d swaps.\n",times);
    else
* * * * * ** *** * * * **** ** train swapping takes %d swaps.\n",times);
    

return 0;
}
answered by (194 points)
edited by
0 0
prog.c: In function 'main':
prog.c:5:9: error: expected expression before '%' token
   scanf(%d,&n);
         ^
prog.c:7:8: error: 'arr' undeclared (first use in this function)
     if(arr[k]<arr[k+1]){
        ^~~
prog.c:7:8: note: each undeclared identifier is reported only once for each function it appears in
prog.c:9:7: error: expected ';' before 'arr'
       arr[k]=arr[k+1]
       ^~~
prog.c:13:13: error: expected ';' before ')' token
   for(flag=1){
             ^
prog.c:13:13: error: expected expression before ')' token
prog.c:15:10: error: 'c' undeclared (first use in this function)
     swap=c[k];
          ^
prog.c:20:5: error: expected ';' before 'return'
     return 0;
     ^~~~~~
0 0
prog.c: In function 'main':
prog.c:5:7: error: array size missing in 'arr'
   int arr[];
       ^~~
prog.c:12:7: error: expected ';' before 'arr'
       arr[k]=arr[k+1]
       ^~~
prog.c:16:13: error: expected ';' before ')' token
   for(flag=1){
             ^
prog.c:16:13: error: expected expression before ')' token
prog.c:18:10: error: 'c' undeclared (first use in this function)
     swap=c[k];
          ^
prog.c:18:10: note: each undeclared identifier is reported only once for each function it appears in
prog.c:23:5: error: expected ';' before 'return'
     return 0;
     ^~~~~~
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 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int n,i,k,j,x,count,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
** * ** ****** ****** ** * ** * * *** * ***** ***
*** * **** ** * ** **** *** ** ** * ****** * * **** * ** ****
**** ** * ** * *** ** * * * * ** arr[x];
** * *** ****** * **** * *** * * * * ** * ** * *** * * * * *
* * * * * * **** ** **** * * ***** ** **** *** * *** ***** **** ** * ** * * * * ** * ** **
* * * * * ** ******** ** ** ** * ** * *** * ****
        {
********** * ** *** ** **** * * * * * * * *** ** * * ** ** *** *** * * * *
** * * *** ** ** * * * * *** ***** ** * * * * ** *** * *** **
** ** * ** * * * ****** * ** * * * * ** * ** * * **** ** ****** *** * * * ** * *** ******** * %d",j,k);
*** ** **** * ** *** * * * ** *** ***** * *** *** ** *** * *** * *** * ** *** * ** * **** ** ***
** * **** * *** ** ** ** * *** * ** *** **** * * ** * * ****** *** * ** * * * **** ** **
* ** * * ** **** * * ** ** ** * **** **** **** * * *** ** * * ** * * * * * * * ** * ** * ** * **** *** * ** * * * * ** * ***
* **** * * * * * ** * * *** * *** * ** ** * **** ** * * ** *** *** * * * * *** * * * * * *** * * * ** **
* * ** * ** *** * * * ** ***** * ** * * * ** ******* * * ***** ***** * * * ** * *** * ** * * * ***** *** * **
* * * * ** * ** * * * * *** **** * * ** ***** ** **** ** * * ***** ** ** * * * * * * ** * **** * *
* ***** ** * ** * * **** ***** * * ** *** ** *** ** ** * *** ********* * ** * * *
***** ** * * *** *** **** ** *** ** * ***** * **** * ***** *
        }
** ** * * ** ******* * * ** ****** ***** **** * ** ** ******* *** train swapping takes %d swaps.\n",count);
    }
    return 0;
}
answered by (100 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: 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,c,swap,temp,flag;
 int j,k;
 int array[10000];
******* **** * **** * *** ** *
 for(j=0;j<n;j++)
 {
    swap = 0;
** **** *** ** * * * ** * *** ** * * *
*** * * * * ** ** **
    {
* ** * * * * * **** ** ** **** * ******** ** ***** ** *
    } ** *** * * * * * *** **** ** ** * * * **** ****** ** **
    flag=1;
******* * * ** ** *** ** *
    {
* *** *** **** * ** * * *** * * * *** * * * * = 0;
*** ** * *** **** ** * * * ** ** * **** ** * * **
** * *** * * **** *** * * ** * * ** * *
* ** * * * *** * ** *** * * * *** * * ** * * ** * *** * **** ** * * * *
* * ** * ** ** **** **** ** * *** ***** *** ** ** * * * * ** ** *
*** ** ** ** * * *** * * * ** * ****** * ** ** **** * * ******** ** ***** * * ***
* * *** ** * ** * ** * * * **** *** * * * ***** ** * * * * * * ******* * * ****** ***** * ****
* * ** *** * * ******* * * * ** * * ***** ** * ********* * ** * * * *** * * **** **** ** ****** *
* ** * ***** *** ** ** **** ** **** * ** **** ** * ** * ** * * * ***** *
* ** * * ** * *** * ** ** * ** **** * * *** *** ***** *** * *** * ** ++;
** ** ** ** *** ** * * * ******* * *** * ** ** *** * ***
** * ** * * ***** *** * * * * * * * **** * ** *
    }
*** ** * *** *** * * ** train swapping takes %d swaps.\n",swap) ;
 } *** * ** ** *** *** **** * * * * *** ** ** ** * * **** ** * *** * *
**** * * * * ****** ** ***** * * * ** *
    return 0;
}
answered by (185 points)
0 0
prog.c: In function 'main':
prog.c:34:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main ()
{
    int n,j,temp,k,z,i,sum = 0,c;
    int arr[1000]={0};
    int t[100]= {0};
* * **** ****** * * * * * * **************
    for (j = 0; j < i ;j++ )
    {
* * *** *** * * ** * * * ** ********* **** * = 0;
* ******** * * * * ** *** *** ** *** * ** ** *** ** * *** ****
* * * ** * * * ** ****** ** *** * ** ** * ** *** ** = 0; k < n ; k++)
*** ** * *** *** ** ******* * * *** **
***** * * *** ** *** ** * * * ** *** **** * *** * * * * *** * * ** * * *
* *** *** * ** * * * * *** * *** * **
* * * * * * * **** ** **** * * *** * **** *** ** ******* ** = 1;
***** ** ******** * * *** * ** ** *** * * *** *** ***
*** ** * * ** *** ** * * * **** ** * * ** * * ** * * *
**** ** ** ** ** * * * * ** * **** ** * ** * ** * * * * *** *** * = 0;
* ** * * * ** * ** * ** * * ** * *** ********* * * * * * * *** * ** **** ** = 0 ; c < n-1 ; c++ )
** ** * * * * * * ** ** * ** * *** * * ** * * **** ** * *** * * * ** * * **
** *** ** *** *** ** *** ** **** * ** * ** * ** ***** *** * ** ** *** ** * * * * ** ********* * * * * * arr[c] > arr[c + 1] )
* * ** * ** *** *** ** ** * ** * * *** * *** ** * ** *** * * ** ** **** * * * * ****** **** * **
*** * ** * ** ********* * * * * * *** *** * ** * * ** *** * * * **** ** ** * * ** ** * * * ** * ** * * ** = arr[c];
* * * ** * ** * * * ** *** ** * ** * * * *** * * * * * * * * * *** * *** * * * **** * * * ** * ** * ****** * * * = arr[c+1];
** *** * ** ** **** * * *** * ***** * ***** ** * *** * ** * **** ** ** ** * ** ** ** * *** * ** ***** ** *** ** * ** * ***** ** * * = temp;
* ** *** * * ** ** *** *** * ******* ** ** ***** * *** *** * * * * * ** * * * ** * * ** * * * * ** * ** ** *** * ** ******* * = 1;
** ******* ** ** *** * * * ****** * * ** *** **** ** ** ** * ** * *** * * * ** * * ** * ** **** ***** ++;
*** * * * *** ** * **** * * ** * *** *** ** * ** **** * * * *** **** ** * * ** ** ** * * * * * * ** * **
* ***** *** ** * *** * * *** ** *** * * *** * ** * ** ** * *** ******* ** * * * **
**** * * ** **** * **** * * ** *** * **** * * * **
**** * * *** ** ** * * ** * sum;
    }
    for (j = 0; j < i ;j++ )
    {
****** *** * ** ***** * ** **** * ***** ** * * * * ***** * * *** ** * train swapping takes %d swaps.\n",t[j]);
    }
    return 0;
}
  
answered by (209 points)
0 0
prog.c: In function 'main':
prog.c:39:5: warning: implicit declaration of function 'system' [-Wimplicit-function-declaration]
     system("pause");
     ^~~~~~
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.\n",times);
** ****** * ** * **** ** * *** ** * ** * * *
** ***** * * * **** ** * ** *** * ** **** ** * * ** * ******** ** * * train swapping takes %d swaps.\n",times);
    }
    return 0;
}
answered by (190 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: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int n, c, arr[10000], temp, swap = 0, flag;
    int j, k, b;
*** ** *** **** * ** **** *** * * * n);
    for(j = 0;j < n;j++)
    {
* **** ** * **** * ******* * *** ******** * * * * ** * * *** ** ** *
** ** * ***** * ** * * * * ** **** * *** **** *** ** ** = 0;k < c;k++)
* **** * **** ** ** ******* * ** ***** ** * ** * * * ** ** * * * *
* ** **** * ******* ** *** * ** * ** ** ** ** * *** * * * * ** * * ** **** *** ** * * ****** * * ***** **** ** * * arr[k]);
* **** * * * ** * * ******** ** * * *** * * ***     
*** * * ** * ** **** *** * * = 1;
** ** **** *** * ** == 1)     
     {
** **** * ** * * *** ** ** *** ** ** * *** ** * ***** ***** ** ****** ** * = 0;k < c-1;k++)
*** ** ** * ****** **** ** ** * * * ** **** * * * **** *** * * * **
* *** *** ******** ******* *** ** *** * ** ** * *** * * * ** **** * * * * *** ** *** * * * *** *** * ** ***** ** * ** * * **** **
* * ** * * * * ** * **** * * ** * ** * ** * ** * ******* * ** * **** * * * ** * * * *** **** * ** * * ** *** * ** **** = 0;
* ** ** *** *** *** * * ** * *** ** * * ** * * ********** ** ** *** * * * ** ****** ** **** ** ***** = arr[k];
* * ** * * * *** *** * * * ** *** ** * * ** *** * ** * ** * * ** **** ** * ** * * ** * * * *** = arr[k++];
* * ** ** **** ** * * *** ** ** *** * * ***** * *** * ****** * **** * * *** *** * ** * ** ** ** **** * **** * * * = temp;
* *** *** * * * * *** * ** ** **** ****** ** *** ** * ** * * *** **** * * *** * ********** ** **** * * ** * * ** ** * ***** * ***
** * * * *** ** * ** *** **** * ** * *** *** * **** * * * * * * ** * * * *** * *** **
* * * * *** * * * *
* ** ** * * * ****** ** ** * *** ** ** train swapping takes %d swaps.\n",&swap);
     }
** *** ** * * * **** *** ** 0;
   
}
answered by (240 points)
0 0
prog.c: In function 'main':
prog.c:6:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d", n);
             ^
prog.c:9:19: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
           scanf("%d",c);
                   ^
prog.c:12:25: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
                 scanf("%d", arr[k]);
                         ^
prog.c:27:45: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int *' [-Wformat=]
      printf("'Optimal train swapping takes %d swaps.\n",&swap);
                                             ^
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main(){
    int n,c,i,j,k,num,times,temp;
******** * * * * * ** *** * * * * * ** * **
    for(c=0;c<n;c++){
** ** * * ** ** * * ** * *** * ** *** *
*** ** * * ** *** ** *** **** * * ** ** * * * * * **
       int train[num];
* ****** * * ** * *** ** *** ** *** * ** **** ***** ** * *
** * ** ****** * ** * ** ** ***** * * * * * * * * * * ** *** *** ** * * ** * ** **** * *
       }
* *** *** **** * * * * ** * ** ** **** * * *** *
***** *** * * * ** * ** * * * *** ** * **** *** **
* * *** ** ** * ** * ** ***** *** * *** ** * * * *****
** ** ***** * * *** ** ** **** * * * **** ** * * * * * * * ** * *** *
* * * *** * ***** ** * * * * **** * **** * ******** * * ** * ** * * **** *** ** ****
** * * * * * * * **** * * **** * * * * ** ** *** ****** * * *** * ** ** * ** * ** * *
* * *** * ****** *** * * * ** * ***** * * ** ***** ********** ***** **** * * * * *** ** ** * * *
** *** *** *** ** * * * * ** * * * * * ** ** *** *** ** ** ** * * * * ** * *
* *** ** * * ** * * * *** * * * * * *** ** ***** ** **** * * ** ** * **
****** * * * * ** * * * * * *** * * * ** *
** * * ** *** ** ** ******** * * * * ****** * ** ** ** ******
       }
* **** *** ******* *** * * ** **** *** ** * * * train swapping takes %d swaps.\n",times);
    }
* **** * ** * ** * ** * * ***** * ** ******* *
}
answered by (192 points)
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,k,j,input,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
* * ******** * ** ** **** * ** ***** ** * ** ***** count=0;
* * * * * * ** * *** *** ** ***** * * ** * * ** ** **** * **** *
** * ** ** **** *** *** * ** * *** * array[input];
* *** ** *** * *** * * ** ** ***** * **** * **** * * * ***
* ** * ** ** ****** * * * ** * ***** ** ****** * **** * * * ***** * * * * ***** * * *** *
* ** ** ** ****** * * * * * * *** ** * * ** * ****
* * ** * * * *** ******** * * ** ** * * * * * *
*** * *** ***** *** ** ** *** * **** *** ** * ********* * * * *** * * *** * * *** * * * **
* * **** ** * ** * * * * *** ** ** * *** * *****
*** ** *** * ** ****** *** * * ** * * * * * ** *** ****** ** *** * * * * * ** *** * * * ** *** ******* **
**** * ** ** * * * ** * * * * * **** * ** *** * * * * ***** * * * * ** ** ***** * * * ** *
**** ***** * * **** * **** * * ** *** * * * **** ***** **** ** **** * *** * ******* * * * *** ******* * * * * * * * * *
** ** * * * ** * * * ** ** ** *** **** ** **** ***** * * ** * * *** * *** *** *** ** ***** * ** * * ** ** * **** **
*** ** * ********** * ** * ** * *** ** **** * * * **** ** ***** ** * * ***** ** ****** * * ** *
** ** * * * * ** **** * ** * **** * * * * **** ** ** **** * *** ****** ***** ** * * ***** ***** * * **** *
**** * * * ** * * * * ** * * ** ** * **** **** * *** * ** * **** ********** ***
* * * * * ** ******** * ** * * * * * * * ** * ***** * * * *
* ** * * * **** ** **** * * * * **** ** *
*** * * ** * * ** * * * * ** * * ** train swapping takes %d swaps.\n",count);
    }
    system("pause");
    return 0;
}
answered by (114 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:108.162.216.57
©2016-2025

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
| 1.5k 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
| 6.3k views
3 like 0 dislike
16 answers
[Exam] asked Dec 23, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 38939 - Available when: 2017-12-23 09:00 - Due to: 2017-12-23 12:10
| 4.4k 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
| 3.1k 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
| 1k views
12,783 questions
183,442 answers
172,219 comments
4,824 users