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

64 Answers

0 like 0 dislike
Hidden content!
** * * * **
int main()
{
** **** **** * a,b,c,d;
* * * * ** * ** * * *** ** * ** *** * ** * * * * ** * *
** **** *
  {
** ** * ******** * * * * *** * ***** ***
  }
* * ** *
  {
*** ******* * * ** ** * * ** ** ** * *** * *** * *
  }
**** * * ** * *
* ** ***
* * * *** * * * * ** ** ***** * * ******* *** * ***
  }
* ** * * * ** ***
*** ** *
*** ** *** ** * * ** * * * ** * * * * *** ***
  }
* * * 0;
}
answered by (-255 points)
1 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 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(){
* * * * * * * * **** *** *** str[4];
** ** *** * * * * ** **
* * ** ** *** ***** ** *
* *** ** * *** *** ** * *** **** *** **
* **** * * ** * ***** ** 0;
}
answered by (-116 points)
0 1
prog.c: In function 'main':
prog.c:5:13: error: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[4]' [-Werror=format=]
     scanf("%s",&str);
             ^
prog.c:6:5: error: implicit declaration of function 'strrev' [-Werror=implicit-function-declaration]
     strrev(str);
     ^~~~~~
cc1: all warnings being treated as errors
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main()

{
* ** * * ** * ** * * a,b,c,d;
*** * ** *** * ** * * * * *** *** * **** **** * * ** **

**** ** ** * ** * ***** *** (d!=0)
* ****** * * *** ******
* ******** * * ***** * ** *** *** * *** ** * * * ** ** *
    }

***** * * *** ** * * (c!=0)
* ******* *** * **** ***** **
* ** * * ** * * ** *** * * ** * * (d==0)
** *** *** * * ** * * * * *** * * ** ** * ***** * ** * ***
* *** ** * * * * * *******

*** * ** * ** * ** (b!=0)
** ****** * * ***
***** *** *** * ** * ** * * ** * * (d==0 && c==0)
**** *** ***** * **** * * * ** ** ***** * * **** ** **** ** *
    }



** * ** * * * ** * 0;
}
answered by (-249 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 * ** * ** **
#include *** ** **

int input[4];
int digit;
int output = 0;
int i;
int main(){

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

* * ** * * * * * ****** += input[0]*1;
* * **** ** * ** * ** += *****
*** * ** * * * * ** **** += ** * *
***** *** ** ** += ***


* ** * * *** ** * ** **** ****** *** *
* ** * * *** * * * * 0;
}
answered by (-286 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 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 ** *** **** * *
#include ******* **

int input[4];
int digit;
int output = 0;
int i;
int main()
{

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

** * *** ** *** * ******** ***
* *** *** ** * * * * ** * * * ** ** *** ****** ** * += input[i]*pow(10,i);
* ** ****** * ** * ** * **

** *** *** ** ** * * * * * *** * * ** *** *
***** * *** ** *** ** *** 0;
}
answered by (-286 points)
0 0
prog.c: In function 'main':
prog.c:14:28: error: implicit declaration of function 'pow' [-Werror=implicit-function-declaration]
         output += input[i]*pow(10,i);
                            ^~~
prog.c:14:28: error: incompatible implicit declaration of built-in function 'pow' [-Werror]
prog.c:14:28: note: include '<math.h>' or provide a declaration of 'pow'
cc1: all warnings being treated as errors
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
* * ** ******** * * a,b,c,d;
* ** * * * ** *** * ** ** ***** * ** * * *** ****** * * ***
    if
*** * * ** * *** * *** * *** ****** *** * && c==0 && d==0)

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

* ***** * * *** *** ** * ** if

** * ** ** ***** * * *** * * ***** *** **** ** * **** && d==0)

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

** **** * ** * ** * if

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

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

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

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

* * ** * ** * *** 0;
}
answered by (-196 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 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 * ****** ** *

int main()
{
*** * a, b, c, d, e, f, g, h, x;
******** * * *** ** *** ** &b ** * * **
** * ** * ****
* * ******* *** **
* ** * * * *
*** ** * **
*** * * * * ** **
**** * ** ** * ***
** * * **** 0;
*** *
answered by (-66 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 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 ****** **
int main ()
{
* * ***** * * *** ** ** n, reversed_number = 0, remainder;
*** ** ** ** *** ** * *** * * * *** &n);
** * * * * (n != 0)
** *** *** * * *** **
*** * * ** * * *** * *** *** ****** * = n%10;
* * ** * * * * * * *** * * *** ** ** * ****** * = *** **** + remainder;
** ****** * ** * *** * * * ** ** *** * *** /= 10;
* * ** *** ** *******
** ** * * ** ** * * * * *** reversed_number);
* * *** * ***** * ** ** * * 0;



}
answered by (-140 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 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 *
int num;

* * ** **
* ** * *** *** * * * * ****
* ** * *** ** * *
* *****
**** **** * *** ** *
*
}
* * * *** * **** **
return 0;
}
answered by (-141 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 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 <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 ;
                         ^~~~
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.126.140
©2016-2024

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