4 喜歡 1 不喜歡
12k 瀏覽

Write a program to swap the values of two variables. The program will ask the user to input variables x and y with numerical values. You must write code that exchanges their values: the value of x after your code runs must equal the value that y had before your code ran, and the value of y after your code runs must equal the value that x had before your code ran.

寫一個交換兩個變數的程式

Example input:

3
5

Example output:

5
3

Remember: Your output may be 100% correct, but your code matters!

[練習] Coding (C) - 最新提問 分類:Chapter 2: C Fundamentals | 用戶: (12.1k 分)
ID: 25484 - 從幾時開始: 無限制 - 到幾時結束: 無限制

修改於 用戶: | 12k 瀏覽
0 0
u

61 個回答

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

int main()
{
** ******* *** * ** *** a,b,swap;
* ** * ****** *** * ** ***** * * * * * **** * *
*** *** * * * * ** ***
***** * ** * * * * ** * * ** *
* * * ** ** ** ** ** ** **
**** ** ** ******* ** ***** * * ** ** ** *
*** * * * * **** ***** * 0;
}
最新回答 用戶: (82 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>
int main()
{
*** * ***** ** * * *** first_number;
** ** ** * ** * **** * second_number;
* * * * ***** * *** ** swap;

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


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

*** ** ** ** * *** * *** * * * * * *** * ** );
* ** * * *** ** *** * ** * *** *** *** * ****
* * *** ** ** ** 0;

}
最新回答 用戶: (-254 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main(){
* ** **** * ** *** a,b,temp;
**** ****** ****** ** ** * ** * * **** * ****
* *** **** * * *** ** * * **
*** * ** *** ** * ** *** * * * *** *** * *** * ** *
return 0;}
最新回答 用戶: (-32 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include<stdio.h>
int main()
{
int a,b;
**** ** * * * * * **** ***** **** * *** *
* * * ** ** * * ** ** ** *** * *
* *** * * * ****** ****** *
* ** * **** * ** ***
* * * ** * ** **** *** ***
***** * ***** ** * ** ** ***** * * * **
return 0;
}
最新回答 用戶: (64 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
** *** * *** *
** ** (){
* ** *
* * ** * *** of x and y: * *** * **
* *** *** *** ** *** ** ** * *
** ** ** of x= %d and the * * of y *** ** *
* ******
*
* *
* * ****** *** x * y * * * * * **


*** 0;
}
最新回答 用戶: (16 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
** ** *** **** *
int * *
{
** * * * * a,b,swap;
** * *** ** ** * *** ** *
*** ** ** ** * ** *
swap=a;
a=b;
b=swap;
** ****** *** * a);
* * * ** *** *
*** * * ** * ** 0 ;
}
最新回答 用戶: (-254 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
* ** ***** *
main()
{
* *** * * **** *
* *** * * **** * * **
*** ** * *** * ** **
swap=a;
a=b;
b=swap;
* **** ** * ** ** a);
* * ** * ** * **
* * * ** * * 0 ;
}
最新回答 用戶: (-254 分)
0 0
prog.c:2:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main()
 ^~~~
0 喜歡 0 不喜歡
內容已隱藏
*** * * *** **
 int main(){
int a,b;

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

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

return 0;
}
最新回答 用戶: (-32 分)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 喜歡 0 不喜歡
內容已隱藏
*** ***** * ***
* **** main(){
int a,b;

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

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

return 0;
}
最新回答 用戶: (-32 分)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

int main(){
***** *** * * *** ***
* * ** ** * *** *** * * x,y,temp;
* ** ** ** ******
** ** ** * * * * ***** * ** *
** * ***** * *** ** ** *** ** **** * *** * ** *
    
** * * *** *** * ** = x;
* **** * * * * = y;
****** ** ** * * * ** = temp;
** ** * * ** * **
* ** * * *** * ** *** * * **** ** * * ***** * x,y);
** * ** ** *** *
** ******* ** * * * * * **** 0;
}
最新回答
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.197.95
©2016-2026

相關問題

2 喜歡 0 不喜歡
50 回答
[練習] Coding (C) - 最新提問 9月 28, 2017 分類:Chapter 2: C Fundamentals | 用戶: thopd (12.1k 分)
ID: 25483 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 11.2k 瀏覽
1 喜歡 0 不喜歡
73 回答
[練習] Coding (C) - 最新提問 9月 28, 2017 分類:Chapter 2: C Fundamentals | 用戶: admin (9.9k 分)
ID: 25482 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 13.9k 瀏覽
3 喜歡 0 不喜歡
116 回答
[練習] Coding (C) - 最新提問 10月 5, 2017 分類:Chapter 3: Formatted Input/Output | 用戶: thopd (12.1k 分)
ID: 25729 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 25.2k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶