2 like 0 dislike
17.1k views

Write a program that input four-digit number, then prints the number with its digits reversed .

寫一個輸入4位數字,反轉輸出這個數字的值

Example input: 

5455

Example output:

5545

Example input: 

5400

Example output:

45
[Exercise] Coding (C) - asked in Chapter 4: Expressions by (12.1k points)
ID: 27669 - Available when: Unlimited - Due to: Unlimited

edited by | 17.1k views

64 Answers

0 like 0 dislike
Hidden content!
#include *** ** * **
int main()
{
******* * * * *** ***
* ** * * * **** *** ***** a,r;
* * * * *** * ** * * * *** ** &a);
* * ** * ** * * = (a % 10)*1000;
* * * **** ** ***** ** * = r + ((a % 100)/10)*100;
** ** *** * * *** * * * = r + ((a % 1000)/100)*10;
*** ** **** * * * * = r + (a/1000);
* * * * * * ** * * *** * *** * * ** r);
** * * * *** * ** ***** 0;
* * * ** ***** * * ** **
**** *** * * ****
* * * * *** * *****
** ** * ** * **
* * * * ** * * * * 0;
}
answered by (-168 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 like 0 dislike
Hidden content!
#include **** ** **
int main()
{
* * * ** * * * * ** n, reversedNumber = 0, remainder;

* * * *** * * * * ** an integer: ");
** *** * ** * **** *** *** *** **** ****** &n);

* ** ** ***** * *** * ** ** * != 0)
* ** ** * *** **
** * ** * ** * * ** * **** * ***** * * ** ** = n%10;
**** *** * * * ** * ****** * **** ** * = ****** * ** + remainder;
* **** * * *** ** * ****** * ** * * * * ** /= 10;
** * * *** **** *** * *

******* * * **** * ** ** ** **** * **** * ** * ** *
return 0;
}
answered by (-167 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
** * *** ** *** * * * ** tab[5],i;
** * **** *** * * * * * * ** **
** * * ** * ** * * * * *
* *** ** ** * * ** * * * * * *** * * ** * ****** * **** * *
* ** **** * ******* * * * *
** ** *** * ** ** * *** (i=4;i>=0;i--)
    {
* * ***** * * ** ******* ** *** ** ** **** * ****** * * * * * ***
** *** * * * *** * * * *
* * * *** ** * * *** * * 0;
}
answered by (-168 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
** *** * ** * * * * ** tab[5],i;
* **** * * * * * * ** ** * * * *
** *** * * * * * * ***
**** * * **** * **** *** *** * ** *** *** * **** * *** * * **
* ** * ** ** * * * **
* * ** * ** * **** ** (i=4;i>=0;i--)
*** ** *********** * ** ****
* * * * * *** * *** * * *** * * * * * ** *** * *** *** ",tab[i]);
*** * * ** ** ** * * *
*** * * * * * *** * * * * 0;
}
answered by (-168 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include * *** * * * *
int main()
{
* * ** * * * ** *** n, reversedNumber = 0, remainder;
* * * **** ** ****** *** ** * * ** * * &n);

* *** * * **** ** ** *** != 0)
* * *** ** ** ** *
** * ** *** * * * * * ** * ********* **** * *** * ** = n%10;
* ** ** *** * * **** * *** * * ** * * * * * ** * * = reversedNumber*10 + remainder;
* *** * * ** * * *** ** **** * ** /= 10;
***** * ** * *****

* * *** ****** *** * *** *** *** *** * * * reversedNumber);

** * * * * *** *** ** 0;
}
answered by (-233 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
**** ** * * * ** a,b,c,d,rev;
** *** *** * * **** * *** * **** ** ******** * *** * *
** * ** * **** * *** ** ***
* * * * ***** ** ** * **** * *
* **** * ** *** * 0;
}
answered by (-32 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include ***** * *** **

int main()
{
** * * *** ** * ***** n, reverse = 0;

**** * * * ***** ***** * ** * &n);

** ** ** *** * * ** * (n != 0)
** * ** * *** *** * * * *
*** *** * ** * **** ** * * ** * * * **** * = reverse * 10;
* ** * *** ** *** *** * * * ** * * * = reverse + n%10;
* **** * ** ** * ** *** ** * ****** ** ** * * * * * * * ****** * * * * n/10;
** ** * * * * * * **** *

** *** * ** ** ** ** * ***** * * reverse);
** ** **** * ** * * * * **** * 0;
}
answered by (-168 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 like 0 dislike
Hidden content!
***** *** ***
int main(void){
int num;

* *** ** * *** **
* * ** * * ** ** ** *
* * *** * ** ** * * ** * *
while(num!=0){ * **** ** * *
*** * ** ** * * *** *** *** ******** ** * * ***
num/=10; ** * ** * ** ****
}
*** ** * ** ** *** *
return 0;
}
answered by (-32 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
0 0
-----------Re-judge-----------
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
Case 5: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
** * * ******* * * * * a,b,c,d;
* * * ** * **** * * * * * * * * *** ** *** ** ** * ***** ** * ** *
****** * *** * * * (d==0 && c!=0)
* * * ** * ** * * **
***** * ** * * ** **** *** * * * ***** * ** * ** * **** ***
* *** ** **** * *** ** * *
* *** * * *** * *** * * if (d==0 && c==0 && b!=0)
* ** ** * ** ** ** * ** *
** *** * * **** ** * *** ** ** * * * **** * * *** **** **
*** ** * *** **
* ****** ** *** * ** if (d==0 && c==0 && b==0 && a!=0)
** ** **** ** ***
*** * *** ** ** ******* * ** **** * ** *** ***** ***
* ** * * * ** *** ***
* * ** * ***** ** if (d==0 && c==0 && b==0 && a==0)
* * **** * * ** *** * **
* *** *** * ** * * ****** *** * * * * **** * * ** * ** ****
* * * ** * * *** *
** ** * ** **** * * ** * * if (d!=0)
** * ** **** ** *
* * * * * *** **** ** ** **** ** * * * ** * * **** * ** *** * ***
****** * * ***** *** * *
}
answered by (-214 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Case 5: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
********* * ** * * **** a,b,c,d;
* *** * ** * **** ** *** **** * ** *** * * ******* ** * * ** * ****
*** ** ***** ** * ** (d==0 && c!=0)
** ** * * *** * ***
* **** ** ** *** * ** *** * * * * * * *** * *** *** ** *** * *
**** **** * ** * * * ** * *
** ** * *** *** ** * **** if (d==0 && c==0 && b!=0)
* ** ** *** *** * * * * * *
*** ** ** ******* ** * * * ** * * ** * ** ** *** ***** * *
** ** *** ** * **
* **** * *** * * if (d==0 && c==0 && b==0 && a!=0)
* * ** ** *** **** ***
* * ****** ** ********* *** * ** * ** *** ***
***** ** * ** **** *
** * * * * * ** *** * if (d==0 && c==0 && b==0 && a==0)
* ** * ** * ** ** ** *
* * * * **** ***** **** * * * * * * ** ** *** * ** * * * ** * ** *** * ** *
* ** ** * ******* **
** *** **** *** * * * ** ** * if (d!=0)
*** * * *** * * * ** ** *
* ******* ** * * **** * ** * ****** * * ** **** ***** * ** * ** *
*** * * * * *
}
answered by (-214 points)
0 0
prog.c: In function 'main':
prog.c:20:16: warning: too many arguments for format [-Wformat-extra-args]
         printf("&1d",a);
                ^~~~~
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.255.50
©2016-2025

Related questions

1 like 1 dislike
85 answers
[Exercise] Coding (C) - asked Oct 26, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 28914 - Available when: 2017-10-26 18:00 - Due to: Unlimited
| 16.5k views
12,783 questions
183,442 answers
172,219 comments
4,824 users