0 喜歡 0 不喜歡
11.5k 瀏覽

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!

[練習] Coding (C) - 最新提問 分類:Chapter 8: Arrays | 用戶: (5.2k 分)
ID: 34913 - 從幾時開始: 2017-11-30 18:00 - 到幾時結束: 無限制

修改於 用戶: | 11.5k 瀏覽

56 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>

int main()
{
** *** ***** *** **** number;
** * ** * ** * array[10];
** ** ****** * ** i;
** * ** *** * ** * * j;

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

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

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

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

**** * * ** ** * ** * * * **** * * * * != array[number-2])
* ** *** *** * **** * * **** * ** * * * *
* * ****** *** * ******* *** * ***** * *** *** **** *** ** ** ** * ");
* * ***** * **** * *** ********* * ****
    }

** ** **** * * *** * * 0;
}
最新回答 用戶: (-140 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
int main()
{
* *** **** *** *** ** * b,c,d;
** * * ** * ** * * * ** * * * * *
****** * * ** * * * ** a[100];
** * ** *** * **** ** * (b=0;b<c;b++)
* ** * *** ***** * ***
*** * **** ** * * ** ** * * * *** ***** **** **** * ** ****** **
* * * * * ****** *
* ** * * *** * * ** * * **** **** **
** *** * ** * ** (b=0;b<(c-1);b++)
* *** * ** ** *** * *

* * *** * ** * * * ****** ** * ** * **** * *** * %d",a[b]);
*** * * ** * * * ***




}
最新回答 用戶: (-66 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
* * * * * ****
using namespace std;
 
int main()
{
** * **** ***** ** ***** A;
* * *** ** * * ** B[100];
* *** * ** * ** * * C;

** ** ** *** * * * * * * >> A ;

***** * * ** * * * = 0;
* * *** * * * *** * C < A)
* **** ** * * ** * **** *
* * ** *** * ** * *** * ** ** ***** * * >> B[C];
* * * * *** *** ** *** *** * **** ** ** * = C+1;
** ** ** * * * ** *

* * * * * *** = A-1;
* ******** ***** * C >= 0 )
******* * * * ** *
* ** *** * * ****** ** **** * << B[C] ** * * * ** * ";
* ** ** * * * ** * * ** * *** **** * ** = C-1;
* * **** **** * * * *


*** * * * **** 0;
}
最新回答 用戶: (-66 分)
0 0
prog.c:1:19: fatal error: iostream: No such file or directory
 #include<iostream>
                   ^
compilation terminated.
0 喜歡 0 不喜歡
內容已隱藏
* **** * ** ****
using namespace std;
 
int main()
{
*** * **** *** * *** * * A;
** *** * ******** * * * B[100];
* *** * ** * *** **** *** C;

* * * ***** * * * * *** >> A ;

** **** ** ** ** * = 0;
** * ** ** **** * * *** * C < A)
** * * ** * ** * * **
* * ** ** **** ** * * *** ** * * *** ** * >> B[C];
** * ** *** * * * * ** ** ** * *** * = C+1;
* ** * * ** ** ** *

** * * * ** = A-1;
* * * ** *** * * * C >= 0 )
** * ** * * *** *
* * ******* * * * *** ** * * * * * ** * << B[C] *** * **** **** ";
* ** * * **** **** *** * ******** ** ** *** = C-1;
** * * * ** *


* * * * * * *** * 0;
}
最新回答 用戶: (-66 分)
0 0
prog.c:1:19: fatal error: iostream: No such file or directory
 #include<iostream>
                   ^
compilation terminated.
0 喜歡 0 不喜歡
內容已隱藏
**** **** * * * *
using namespace std;

int main()
{
* ** *** ***** * ** * ** A;
*** * ****** * B[1];
* * *** * *** * * C;

**** * * * * ** ** ** >> A ;

* * * **** * *** * = 0;
** * ** ******** ** *** ** C < A)
*** ***** ** * * ** * ** *
**** * * * *** ******* ** ** * * * ******* * >> B[C];
***** ** * * **** * * ** * * * ** **** = C+1;
***** ** **** * * * * ** * *

* * * *** * * * = A-1;
* * * ** *** *** * C >= 0 )
* *** ** * * * ***
* ** * *** * **** ** * **** ** *** ** ** ** << B[C] * * * * ";
* **** ** ****** ** ** *** * * = C-1;
* *** * * * **


* ** * ****** *** ** 0;
}
最新回答 用戶: (-66 分)
0 1
prog.c:1:19: fatal error: iostream: No such file or directory
 #include<iostream>
                   ^
compilation terminated.
0 喜歡 0 不喜歡
內容已隱藏
** *** *** *
int main (){
int a[10];
int
* *** *** series of number: **** *
* ******* * **** * *
*** * * **** your * ** *
** ** * *
* * * *** * *** *
***
** ***** * *** * *
* *** *
* *
*** * * *
** * * * *** ** ****
return 0;
}
最新回答 用戶: (16 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include * * * ** * *

void printArray(int arr[]);
void * *** * arr[]);
int SIZE;

int main()
{
* * ** ** * * i, N =1;

* * ** ***** * ** * *** ** * ** ** * * ** **
** ** * ** * ***** ** * arr[SIZE];

**** * * * * ** *** i<SIZE; i++)
*** * * * ** ***** * *
* * * * * *** * * *** * ******* * * * ** * ** *** * * * * *** ** * * ** **
* ** * ** * *** * **

* **** ** ** ***** ** * * * = N % SIZE;

**** * ** * ** ***** *** * i<=N; i++)
* * * *****
* * * ***** **** ** * * * ****** **** * ** **
** ** * * * **
* * ** *** * **** ** * **

* * ** ** ** * * ** ** 0;
}

void ** ** arr[])
{
** * * *** **** *** * * i, last;

** ** * *** * ** ** ** ** = arr[SIZE - 1];

* ** * ** * * * **** * *** i>0; i--)
** ** *** * ** * * * *

* * ** * ** *** * ** * * **** ** ** * * * * ** ** * = arr[i - 1];
** *** *** * * **** **
* ** ** * ** *** ** * * * = last;
}

void printArray(int arr[])
{
*** ** ** ** * * * * ** i;

* ** *** ** * * ** * * i<SIZE; i++)
***** * **** *** * ** * ***
* * * *** ** ***** * * **** * * ** * * ** *** * ", arr[i]);
* * ** * * *** * * * **
}
最新回答 用戶: (-168 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include ***** ** * *

void printArray(int arr[]);
void rotateByOne(int arr[]);
int SIZE;

int main()
{
*** * * * ** ** * * i, N =1;

** * ** * ** *** * ** *** * ** *** * *** * ****
* * ** * * * * * ***** ** arr[SIZE];

* ** ** * *** **** * * i<SIZE; i++)
****** * * * * ** ** * *
* ** * * * ** ** * * ** * * ** * * *** *** * * ** ** ** *** *
* ** ***** * *** ** *

* *** * * ***** * * ** = N % SIZE;

* ** * * * *** ***** ** i<=N; i++)
** *** ** * * *** ** **
* ** * ** * * * ***** ** ** ***** ** * * **** *
** ******* * * * *

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

**** *** ** * * * ** ** 0;
}

void ** *** *** arr[])
{
* **** * *** ** *** * i, last;

* ** * * ***** ** * * = arr[SIZE - 1];

* ** ***** * **** * ** *** i>0; i--)
* ** * *** * * ** **

*** *** * * ** * *** ******* ** * *** **** **** ***** * = arr[i - 1];
* * ** * * *** ** ****
* **** ********* ** *** *** = last;
}

void printArray(int arr[])
{
****** * ** * *** ** * *** ** ** i;

* * * *** **** * ** * *** ** i<SIZE; i++)
** * * * *** **
*** *** ** * * ** ** **** *** *** *** * * * ***** *** ", arr[i]);
******* *** **** ** ** *
}
最新回答 用戶: (-168 分)
0 0
prog.c: In function 'main':
prog.c:26:12: warning: zero-length gnu_printf format string [-Wformat-zero-length]
     printf("");
            ^~
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>

int main()
{
* * **** *** *** * **** number;
*** * ** **** * * * * array[10];
* **** ******* **** * * i;
* *** ** * * *** **** j;
**** **** * ** * ** *
* ** * **** * *** * ** ** * ** * * * * *
    
** **** * ** * * * ** *** **
** ** * ** * ** ** * * ****
* *** * ** ** * * *** * ** ** * ** **** **** * * * ***** *****
******** * *** ** * * *
    
** * * * ** *** ** *** * * * * ** ",array[number-1]);
    
* *** * ** ***** * ** ***** * *** *
** * * ** * ** * *
* ** **** * * * *** * ** *** * * * * * ** * * *** ** **
** ***** * ** ********* * ** *** * * *
* ** ** **** * * ** **** * ** ** ** ** ***** * != array[number-2])
*** * *** ** * * ** * *** * ***
*** ** * **** * * ** ** * ****** *** * ** *** * * * * ******** ");
*** *** ****** * * *** ** *** * ***** * *
* * ** * ** ** * **
    
* * * * ** ** ** **** ** 0;
}
最新回答 用戶: (-193 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>

int main()
{
** ** * ** ** * * number;
* * * ** **** *** ** *** * * array[10];
** *** * * ** ** **** i;
* * * * ** * * * * j;
    
*** * * ** * *** * **** ** ** ** ** ** * * *** *
    
** ** ** * * **** * ** *** ***
* *** * *** * *****
** * ***** * ** * * *** * ** * * * * ** * ** ** * **** * * ** * * * *
** *** * * *** * * *
    
* ****** * ** ** *** * * * * * * *
* ** ****** ***** * *
* ** * ** **** * ** *** * ** * * * **** * * * * * * * ******* ***
*** *** * ********** ** * *** ***** ** * ** **
**** ******* * ** ** ** ** ** **** * ***** **** != array[0])
** * * * ***** * **** * * *** * ****** *** *
* * ** * * *** ** * * * * * * * ** ** * *** * * *** * ******* * * *** ** ");
* * * **** ** *** * * *** **** * **** **** **
* * * * * *** *
    
* * ** * ** * * * *** 0;
}
最新回答 用戶: (-193 分)
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.111.110
©2016-2025

相關問題

0 喜歡 0 不喜歡
55 回答
[練習] Coding (C) - 最新提問 11月 29, 2017 分類:Chapter 8: Arrays | 用戶: semicolon (5.2k 分)
ID: 34968 - 從幾時開始: 2017-11-30 18:00 - 到幾時結束: 無限制
| 11.5k 瀏覽
0 喜歡 0 不喜歡
46 回答
[練習] Coding (C) - 最新提問 11月 29, 2017 分類:Chapter 9: Functions | 用戶: semicolon (5.2k 分)
ID: 34912 - 從幾時開始: 2017-12-14 18:00 - 到幾時結束: 無限制
| 10.9k 瀏覽
0 喜歡 0 不喜歡
31 回答
[練習] Coding (C) - 最新提問 12月 28, 2017 分類:Chapter 8: Arrays | 用戶: semicolon (5.2k 分)
ID: 39985 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 9.7k 瀏覽
0 喜歡 0 不喜歡
102 回答
[練習] Coding (C) - 最新提問 12月 28, 2017 分類:Chapter 8: Arrays | 用戶: semicolon (5.2k 分)
ID: 39984 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 21.1k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶