0 like 0 dislike
9.8k views

Write a program that reads integers and stores them in an array. Then, the program should rotate the elements one place to the right. For example, if the array were 1, -9, 5, 3, the rotated array would be 3, 1, -9, 5.

寫一個程式 輸入整數放在陣列裡。將陣列裡面的元素向右旋轉一次

Example input 1: First number is the element of array to input, then the list of numbers

4
1 -9 5 3

Example output 1:

3 1 -9 5

 

Example input 2:

5
2 7 9 3 12

Example output 2:

12 2 7 9 3

Please remember, you may correct the cases, but your code always be revised!

[Exercise] Coding (C) - asked in Chapter 8: Arrays by (5.2k points)
ID: 34913 - Available when: 2017-11-30 18:00 - Due to: Unlimited

edited by | 9.8k views

56 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
**** * * ** ** * tab[10],m,c,i,b,cpt,d;
* * *** ** *** * **** ***
* * ***** * ** *** *** ** * **** **** **
*** *** ******** * *** (i=0;i<=m-1;i++)
* * ** ** * ** * * *
**** ** * ** *** * * ***** ** * ** * *** **** ** * * **** *** * *** * * **
    }

* * * *** ******* * ***** *
** * * * *** *** * ****** * * (i=m-1;i>=1;i--)
    {
* * * * * ** * * ** ** * *** ** * * ***
    }
* * *** ** ** *** ** * * * * **
* ** * *** * * * * (i=0;i<=m-1;i++)
** * *** ** ** * * ***
* *** * * **** ** * ******** * *** * * * **
* *** **** * * ** ** * **** ** ** ***** * ***** * * ** ** * * **
* * * **** *** *** * * * **** *** *** (i>0)
* *** ** ** ** **** * * * ****** *
****** ** * *** * * * *** * ***** * ** * * ********* ** * ** * * %d",tab[i]);
** * *** * ** * *** * *** * ** ** ** ** *
* ** * * * * * ***
**** * * ** * * ** ** 0;
}
answered by (-168 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
** ** * * * ** * a,i,temp;
* * * * ** ** * * * * * * * * ** *
* * ** ** * * * * *** c[a];
****** ** * * ** * * * ** * ****
* * ** ** ** * ** **
***** ** * *** * ** * *** * *** * * ** *** *** * * * *** ** *
    }
** *** * ******** ***** ** * * ***
    {
** * * * ** ****** ** * * *** ** * **** * ** * *
* ** * ** ** * *** * ** * * * ** ** * ***
***** * * *** ** *** * * * * * *** ** * ** ** *
    }
* ** * ** * ** ** * * *** **** ***
    {
********* ** * * *** ** * * *** * *** **** * * **
** * * ****** ***** * **** * *** * * *** * **** * * * *** ****** **** * ** ** ** ***
* * ** ** * ** *** ** ** ** ** * ** ****** ** *** **
** ** ** * *** * * * *** *** * * ** *** ***** * * ***** * *** *** * * * ** * * %d",c[i]);
** * **** *** *** **
* ** *** ** * ** ** ****** 0;
}
answered by (-258 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main() {
   
** ** ** ***** * * * i,num,ar[20],temp;
    
* ** * ** ** * ** * * * &num);
* * *** * * * ********
****** ** ** **** * * ** * (i=0;i<num;i++){
*** * * *** ** ** **** * ** * *** * *
* * ** * **** ** * * * * *** ** * * * ** * * ***** ** * * &ar[i]);
** * * ** * * * * ** * *
* ** * ** *
* *** * * * *** * * = ar[num-1];
** ** * * * ** * * * ** *** *** * *
** * * ** *** * * * * ** *** * *
* ** * * ** * ** ** * **** ** ** ** * * * * = ar[i];
* * * * *** * * ***
* * * * * ** **** = temp;
    
** ** ** *** *** *** *** * * * * **
*** * * * * * *
***** ****** ** * * **** * *** * * * * ** * * ** * ** ** ** *** *** ar[i]);
*** ** * * * * ** ** * * **** ** * ** * * ** * (i<(num-1))
* * * * ** ** * ** * ** ** * ** ** * *
** *** * * * ** * * * ****** **** * ** * * *** * * * ******** * ");
** **** *** **** * ** *** ** ***** *** * **
*** ** * * * * * ** **
    
***** ** * * ** 0;
}
answered by (323 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
*** * *** *** * ** i;
** *** ** * **** * *** * * * * * ****** * ** * *

* ***** *** * * *** * a[i],x;

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

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

**** * * * *** *** ****** * *** * * **
******* * *** * * ** ** **** **
** * ***** * * ** * * * * * * **** * *** * %d",a[x]);
    }


******* * ** * * * * * * 0;
}
answered by (-16 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
* * ** * * ** **** * tab[10],m,c,i,b,cpt;
***** *** ** **** * * ** ******* * *** * ***** *
* ***** * * * * ** (i=0;i<=m-1;i++)
* * **** ** * * * * *
* * * * ** ***** ** * * *** *** * *** ** * * ** * * ****** * * ** * **
** * * * *** ***** * *
* **** ** ** * ** **** *** *
** * * * ** * **
* * ** * * * ** * * (i=0;i<=m-1;i++)
*** * * * **** *
* ** * * *** *** ** ** * *** * * *** ** **
*** * * ** * * ** ****** *** * ***** ****** *** *** * *** **
** *** * ** *** *** * ** * ** *** * * *
** *** * * * * *** ** *
** * ***** * * *** ******
* * * * ** ***** * * * (i=0;i<=m-1;i++)
    {
* ***** ****** *** ******* * ** * * *** * * *** * * **** * *** *
    }
*** * ** ***** *** 0;
}
answered by (-168 points)
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 fib(int n);

int main(){

 
* **** ***** ** * * n;
****** * * **** * * ** ** **** * * ** * *
* ***** *** *** * ***** a[n];
* *** * * * ** * ***** (int i=0;i<n;i++){
**** ** **** ** ****** * ***** * **** * **** ** * * ***** * * **** * *** **
* ** * * *** * ** * ***
* * * ** *** ** * * ** ******** * * ** *
*** ** *** * ** * ** * *** (int * ** *** **
***** *** * ***** ****** **** ** * * ** * ** * **** ** *** %d",a[i]);
***** **** * ** ****** *
* * * * ** * * * 0;
}
answered by (-167 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
***** *** ***** * **** * * * n,i,array[100],count=1;
* * *** * * *** **** * ** * ** * ***

*** ** * ** * *** **** * * i<n; i++)
* ** * ** * ** * *
** * * ****** * ** ** * *** ********** * * ** ** * * * *** **** *
**** * * * ***** * * *
*** * ***** * ** *** ** *** * **** * ***
** * * * ***** ** ** ** i<n-1;i++)
**** * ** * ** * *
* * * * * * *** * * * * * * * ** ** * * **** %d",array[i]);
* ** * * * ** * *

*** *** * * ** * * **** 0;
}
answered by (-281 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
* ** * ** * ** **
int ** *
{
** *   int n;
** *** * *** * * ** ******* *** * *
* * ** *
*   int a[n];
* ** ** *** * int i;
* ****   * * * *** ****
*** *   {
* ** * * * **** ** **** * ****** * ** ** *
** ** * * * * }
*** ** * * * * * *** **** **
**** *** **
*** * * * *** * * ** * ** *
* **** * ** {
** *** * *** ** ** ** * ** * * * *** * * ** *
*** * * ** }
* *** * ***
* ** * *** return 0;
}
answered by (-249 points)
edited by
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
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main()
{
** * *** * **** *** * *** ****** * i = 0;

************ ** *** ** * * * &i);

* * ** ** * * *** *** array[i];

** * * * * * * *** ** j = 0;

* * *** * **** = 0; j < i; j++)
* * * ** * ** ** **
* * ** ** ** ** * ** * ** ** **** * * * * * ****** **** * * * &array[j]);
    }

* **** * * *** *** **** ", array[i - 1]);

***** * * *** * * * * ** = 0; j < i - 1; j++)
** *** ** * * ****** ******
*** ** * ** * *** * ** * ** * * * * * == i - 2)
* *** * *** ** ***** ***** * * * ** * **
* * * * **** * ** * ** * * * ******** * ** **** * ** * *** ** * * * *** * array[j]);
** ** * * * *** ** * ** ** **** *
* ** *** * ** * ** ** * * * * * *** * *** ** ***
* * * * ** ** * * * * * * * ** **** *
*** *** * * *** ** ** * *** * ** *** * * * * * ** ** *** ** ***** ** * ", array[j]);
*** ** *** * * * * * * * * *** ***** ***** * * **
*** **** * ** *** * * *
}
answered by (-285 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
**** * * *** * *

int main(void)
{
* *** ** *** ** ** N,i,temp;

*** * * **** * *** ** * * * * * * * * *****
* ***** *** * **** * * a[N];
* ** ** * ****** * * * (i=0;i<=N-1;i++){
** ** * ** ** *** * * *** * * **** *** * ** ***** **** ** **** * **
* **** * * **
 
* * ** * ** * ** * ** ** * ** ** ***** ",a[i-1]);
*** * * ** * *** ** * (i=0;i<=(N-1);i++){
** * * ****** * * ** * ** ** * ****** ** ** ****** ",a[i]);

**** * ** ** * * **
** * ** ** * * * *** * 0;
}
answered by (-167 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
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong 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.100.69
©2016-2025

Related questions

0 like 0 dislike
55 answers
[Exercise] Coding (C) - asked Nov 29, 2017 in Chapter 8: Arrays by semicolon (5.2k points)
ID: 34968 - Available when: 2017-11-30 18:00 - Due to: Unlimited
| 10.3k views
0 like 0 dislike
46 answers
[Exercise] Coding (C) - asked Nov 29, 2017 in Chapter 9: Functions by semicolon (5.2k points)
ID: 34912 - Available when: 2017-12-14 18:00 - Due to: Unlimited
| 8.7k views
0 like 0 dislike
31 answers
[Exercise] Coding (C) - asked Dec 28, 2017 in Chapter 8: Arrays by semicolon (5.2k points)
ID: 39985 - Available when: Unlimited - Due to: Unlimited
| 8.2k views
0 like 0 dislike
102 answers
[Exercise] Coding (C) - asked Dec 28, 2017 in Chapter 8: Arrays by semicolon (5.2k points)
ID: 39984 - Available when: Unlimited - Due to: Unlimited
| 18.6k views
12,783 questions
183,442 answers
172,219 comments
4,824 users