用c 編寫已知abc cba 1333,程式設計求出滿足條件的所有a b c組合

時間 2022-04-10 01:22:19

1樓:

最直接,不用多想的方法,就是列舉了。

把所有的3位數都來一遍~

2樓:匿名使用者

#include

int main()

printf("\n");

return 0;}

3樓:匿名使用者

沒看懂....

你這裡的abc+cba = 1333是什麼意思?

a*b*c+c*b*a == 1333 還是 (a*100+b*10+c) + (c*100+b*10+c) == 1333 ???

已知abc+cba=1333,其中a,b,c均為一位數。程式設計求出滿足條件的a,b,c的所有組合。

4樓:匿名使用者

這種題重點不在寫**,而在於演算法,完全是數學題。

因為abc + cba = 101(a+c) + 20b=1333很明顯,1333中個位數的3必然來自101(a+c),所以a+c要麼等於3,要麼是13.

如a+c為3,那麼20b=1030,b不是一位數,不成立。

如a+c為13,那麼20b=1030-1010=20,所以b=1所以組合很簡單了, a+c=13,同時b=1就行。這樣再列舉,效率高多了。

5樓:匿名使用者

#include

#include

main()

6樓:

因為

&a,&b,&c是列印他們的位址

printf("%d,%d,%d\n",a,b,c);就可以了btw:為什麼a,b初始化為1,b初始化為0?

7樓:匿名使用者

int a,b,c,i,j,k;

for(i=3;i<10;i++)}}

system("pause");

return 0;

8樓:匿名使用者

把輸出語句中的&去掉

已知abc+cba=1333,其中a,b,c均為一位數,程式設計求出所有滿足條件的a,b,c所有組合。

9樓:匿名使用者

樓上回答已經很完備 亦可以改寫為

cout<

cout<

cout<

cout<

10樓:匿名使用者

這是c++語句,可以改為printf("%d%d%d\n",a,b,c);

已知abc+cba=1333,其中a,b,c均為一數字,編寫乙個程式求出a,b,c

11樓:諾諾百科

//注意a,c都是百位上的數,不能為零,程式:

#include

main()

int a,b,c;

for(a=1;a<10;a++)

for(c=1;c<10;c++)

for(b=0;b<10;b++)

return 0;

12樓:任其逍遙自在

把if()後的分號去了

你工程沒有建立,你看程式上面灰色字型「no members-....",正常情況下應該顯示」main"

13樓:it孤鶩

把 if(); 後面的 分號去掉

14樓:

if條件那一行的最後面去掉分號

15樓:匿名使用者

你那判斷後有冒號等於空判斷不做什麼事!

c語言:已知abc+cba=1333,其中a,b,c均為一位數,編寫程式求出a,b,c分別代表什麼數字。 10

16樓:匿名使用者

#include "stdio.h"

for(int a=0;a<10;a++)}}

以知abc+cba=1333,其中a.b.c均為乙個數,例如617+716=1333,程式設計求出符合

17樓:

dty@ubuntu:~$ cat a.c#include

int main()

dty@ubuntu:~$ gcc a.cdty@ubuntu:~$ ./a.outa=4 b=1 c=9

a=5 b=1 c=8

a=6 b=1 c=7

a=7 b=1 c=6

a=8 b=1 c=5

a=9 b=1 c=4

abc+cba=1333,其中a、b、c均為一位數,編寫乙個程式求出a、b、c分別代表什麼數字。

18樓:桐珹

a*100+b*10+c+c*100+b*10+a=1333a*(100+1)+c*(100+1)+20*b=1333(a+c)*101+20b=1333

(a+c)*101+101b - 81b=1333(a+b+c)*101=1333+81b

(a+b+c)*101=101*14-81+81b(a+b+c)/14=14*(1+b)

但是a+c=3或是13 及a+b+c要能整除14, a+c=3不成立

a+c=13, 所以 b =1

a+c = 13的組合有7+6, 8+5及9+4所以會是914+419=1333

815+518=1333

716+617=1333

19樓:匿名使用者

option explicit

private sub command1_click()

'abc + cba = 1333

dim a as long, b as long, c as long

for a = 0 to 9

for b = 0 to 9

for c = 0 to 9

if a <> b and a <> c and b <> c then

if clng(a & b & c) + clng(c & b & a) = 1333 then

print a; b; c, a & b & c & " + " & c & b & a & " = " & clng(a & b & c) + clng(c & b & a)

end if

end if

next

next

next

end sub

用c語言編寫 檔案讀寫,用C語言編寫 檔案讀寫

第一種 include include include struct student 結構體s 50 void daoru struct student s,int n 檔案匯入函式 else fclose p void paixu struct student s,int n 排序函式 int i...

用c語言編寫宿舍管理查詢系統,用C語言編寫宿舍管理查詢系統

定義結構或者類,類屬性包括姓名 學號 房間號 include stdio.h include stdlib.h 標準庫函式 include ctype.h 字元操作函式 include string.h typedef struct studentsaddress 以下是函式原型 int enter...

用c編寫賓館客房管理系統,用C 編寫賓館客房管理系統

void inquire printf n printf n k 0 printf 下列房間已預訂 n for j 0 j 80 j k 0 printf n printf n printf 下列房間有人入住 n for j 0 j 80 j printf n printf n else if in...

用c語言編寫隨機點名程式,用C語言編寫乙個隨機點名程式

include include include define stu num max 4struct studentinfo 學生資訊結構stu stu num max void writedata 寫入學生資訊if fp fopen myfile.dat ab null for int j 0 j...

用c 編寫分數計算器,用C 編寫分數計算器

貌似樓上的是大神,linux下編寫的哦。如何用c 寫乙個簡單的計算器程式 include using std cin using std cout int main return 0 如果不限定for或while,還有兩種簡單思路 輸入乙個string遍歷字元,搜尋符號 2.while cin in...