2 thích 0 k thích
7k đã xem

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) - đã hỏi trong Chapter 4: Expressions bởi (12.1k điểm)
ID: 27669 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn

đã sửa bởi | 7k đã xem

64 Trả lời

0 thích 0 k thích
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;
}
trả lời bởi (-168 điểm)
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 thích 0 k thích
Hidden content!
#include ***** * * * ***
int main()
{
** *** * ** * * * * * * n, reversedNumber = 0, remainder;

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

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

**** * ***** * ** ***** ** * **** **** * ******* * * * *
return 0;
}
trả lời bởi (-167 điểm)
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 thích 0 k thích
Hidden content!
#include<stdio.h>
int main(void)
{
** ** * * * * ** * ** tab[5],i;
* * * * * ** * **** * **** ***** **
** * ** ** ** ** * ** ***
* * * ****** ** * * * ** * ** * * * ** *** * ** ** * ** ** *
* * *** * * *** * *
* * * *** * ** * * ** *** (i=4;i>=0;i--)
    {
* *** * * * ** ** * ** * *** *** * *** ** ***** **
** * * * * ** ** ** *
* ***** ** * * ** * * 0;
}
trả lời bởi (-168 điểm)
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 thích 0 k thích
Hidden content!
#include<stdio.h>
int main(void)
{
* ** * * * **** *** * * * tab[5],i;
******** * * * * *** ****** * * ** *
** ** *** ** * ** ** ****
* *** ** **** *** * ** * * * * *** * ** * *** ** * * * * ****
****** * * * * ** * *
* ***** ** * * * ** (i=4;i>=0;i--)
** * ** * * *****
* * * * * * * * * * ***** **** * * **** ",tab[i]);
** * ** ***** * **
* *** * * * * **** 0;
}
trả lời bởi (-168 điểm)
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 thích 0 k thích
Hidden content!
#include **** * *****
int main()
{
* ** ** ** * *** *** * n, reversedNumber = 0, remainder;
* * *** * **** *** ** * *** *** **** ** &n);

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

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

* ** * * * * * * * * *** 0;
}
trả lời bởi (-233 điểm)
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 thích 0 k thích
Hidden content!
#include <stdio.h>
int main()
{
** * *** * *** a,b,c,d,rev;
*** * ** * * ** * ** * * ** ****** *** * ** ** *** * * ***** ***
**** **** ** * **** * * ** * *
* ** * ** * * **** * ** ** *** * ** *
* * *** ** * *** ** * 0;
}
trả lời bởi (-32 điểm)
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 thích 0 k thích
Hidden content!
#include <stdio.h>
#include * ***** ***

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

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

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

* ** ****** * * * ** * ** ** * *** *** reverse);
** * *** ******* * * 0;
}
trả lời bởi (-168 điểm)
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 thích 0 k thích
Hidden content!
**** * ** **** ** ***
int main(void){
int num;

* *** ** ** * * **** *
* * * ** ****
* * * * ** * * **
while(num!=0){ ** * ** * * ***
**** * ** * ** * * * * * * *** ** * **
num/=10; ***** ** * ** ** ** **
}
* * * * ** * *
return 0;
}
trả lời bởi (-32 điểm)
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 thích 0 k thích
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)
* * * *** *** ** * ***
* * ** ** * * ** ** *** ** * *** * *** * * ** * * * *****
* ** *** ******* ** *
}
trả lời bởi (-214 điểm)
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 thích 0 k thích
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)
*** * * * * *** ** ***
** *** **** ** * *** * * * ** * * *** **** **** * ***** ** **
* ** ** ** * *****
}
trả lời bởi (-214 điểm)
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.70.100.224
©2016-2024

Những câu hỏi liên quan

1 thích 1 không thích
85 trả lời
[Exercise] Coding (C) - đã hỏi ngày 26 tháng 10 năm 2017 trong Chapter 6: Loops bởi semicolon (5.2k điểm)
ID: 28914 - Xem được từ: 2017-10-26 18:00 - Hiệu lực đến: Không giới hạn
| 6.5k đã xem
12,783 câu hỏi
183,443 trả lời
172,219 bình luận
4,824 thành viên