2 like 0 dislike
21.7k 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 | 21.7k views

64 Answers

0 like 0 dislike
Hidden content!
#include <stdlib.h>

using namespace std;

int main()
{
* * * *** ** *** * ** ** x;
*** * * * * * ***** **** **** ***
**** ** * * * ** * * * ** * * * **** * ** *** ** * * **** ****** *          
* * ** * * * * * * * *** ** *** *** * *** ** * * **
***** ** **** ** * * **** *** * ** * *** ****** *** * * ** ** * ** ** *** **** *      
* *** * ** ***** * * ** * *** * * ****
**** ** * * * *** * * * *** * *** ** ** * ** * *** *** ** * * ** ;
***** * ** * *** * ** *
* * *** *** *** ***** **** 0;
}
answered by (-141 points)
0 0
prog.c:3:1: error: unknown type name 'using'
 using namespace std;
 ^~~~~
prog.c:3:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
 using namespace std;
                 ^~~
prog.c: In function 'main':
prog.c:7:5: error: unknown type name 'string'
     string x;
     ^~~~~~
prog.c:8:11: error: 'cin' undeclared (first use in this function)
     while(cin>>x){
           ^~~
prog.c:8:11: note: each undeclared identifier is reported only once for each function it appears in
prog.c:10:24: error: request for member 'length' in something not a structure or union
         for(int i=0;i<x.length();i++){
                        ^
prog.c:11:22: error: request for member 'length' in something not a structure or union
             re[i]=x[x.length()-i-1];
                      ^
prog.c:13:9: error: 'cout' undeclared (first use in this function)
         cout<<atoi(re)<<endl ;
         ^~~~
prog.c:13:25: error: 'endl' undeclared (first use in this function)
         cout<<atoi(re)<<endl ;
                         ^~~~
0 like 0 dislike
Hidden content!
#include <iostream>
#include * ** * * * **** **

using namespace std;

int main()
{
** * * ** * *** ** * * *** x;
* *** * ** * ** * * ** *** * ** **
* * * *** ** * **** *** *** * * *** ** **** **** ** ** ** * * * *          
* * ** *** ** * ** * * * ** * * * **** ** ***** * ** * * * *
* *** ** ** **** * **** * * * * * * * ** * ** * * * ** * * * * * * ** * **** * * * *      
****** * **** ** * * ** * * * *** * ***
** **** * * ******** ** *** * * * * * * * * *** * ** * * ;
* ** * * **** * *** * **
* *** ***** * * * * * ** * 0;
}
answered by (-141 points)
0 0
prog.c:1:20: fatal error: iostream: No such file or directory
 #include <iostream>
                    ^
compilation terminated.
0 like 0 dislike
Hidden content!
* * ** * **** **
**
{
* * * * * * *
** * ** ** * ***
a = ****
*** * * * * ** = *

c = *
*** *** ** * * * * * * * ** = **

e = *
* * ** * ** * = **

g = **
** **** *** = *

* = c;
* = **
* = * *

* ** = *
* =
* = ***


= * ** * * ** *
** * ** ** * * **

*
}
answered by (-141 points)
0 0
prog.c: In function 'main':
prog.c:4:19: error: variable 'h' set but not used [-Werror=unused-but-set-variable]
 int a,b,c,d,e,f,g,h,v,swap,temp,sum;
                   ^
cc1: all warnings being treated as errors
0 like 0 dislike
Hidden content!
*
*
***** * * * ****
* * ***** ** *** ** ***
a = ***
* ** * **** *** * ** = ***

c =
*** * * ** *** ** = * *

e = **
*** * ***** ***** **** = *

g =
** ** ******** * * = * *

* * =
* =
= * *

* = *
= *
* = *


*** = * **** * ***
**** ******* **** *

**
*
answered by (-141 points)
0 0
prog.c: In function 'main':
prog.c:4:1: error: implicit declaration of function 'scanf' [-Werror=implicit-function-declaration]
 scanf("%d",&v);
 ^~~~~
prog.c:4:1: error: incompatible implicit declaration of built-in function 'scanf' [-Werror]
prog.c:4:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
prog.c:27:1: error: implicit declaration of function 'printf' [-Werror=implicit-function-declaration]
 printf("%d",sum);
 ^~~~~~
prog.c:27:1: error: incompatible implicit declaration of built-in function 'printf' [-Werror]
prog.c:27:1: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:3:19: error: variable 'h' set but not used [-Werror=unused-but-set-variable]
 int a,b,c,d,e,f,g,h,v,swap,temp,sum;
                   ^
cc1: all warnings being treated as errors
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.197.117
©2016-2026

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
| 22.1k views
12,783 questions
183,442 answers
172,219 comments
4,824 users