Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

請問一下,一個信用卡公司的程式

0 views
Skip to first unread message

Guitar and Blues

unread,
May 1, 2001, 11:59:20 AM5/1/01
to
這是一個信用卡公司的程式
請問一下高手
下面的問題要怎麼寫出來

信用卡公司有集點換獎品的活動
這些獎品的點數為 3500 4500 5000 6000 6500 7000 8500 12500 18000 20000
要如何寫一個程式能將你有的點數來換獎品的獎品的所有解
且每個解一定要達到最後剩下的點數無法再換任何獎品
而且要將全部解都output出來

請高手幫忙啊
謝謝~~~~~

--

I've got a desire deep in my heart,
A lonely feeling that's tearing me apart.
I don't want a woman or money or a car.
What I really need now is an acoustic guitar.

--
[1;31mO [1;32mr [1;33mi [1;34mg [1;35mi [1;36mn [1;31m: [1;36m<不良牛牧場> [1;33mzoo.ee.ntu.edu.tw [1;32m(140.112.18.36) [m
[1;32mWelcome to SimFarm BBS [1;36m-- [m [1;31mFrom : [ [mn042.n203-107-5.eranet.net [1;31m] [m

深藍

unread,
May 4, 2001, 6:01:45 AM5/4/01
to
※ 引述《slowha...@zoo.ee.ntu.edu.tw (Guitar and Blues)》之銘言:

> 這是一個信用卡公司的程式
> 請問一下高手
> 下面的問題要怎麼寫出來
> 信用卡公司有集點換獎品的活動
> 這些獎品的點數為 3500 4500 5000 6000 6500 7000 8500 12500 18000 20000
> 要如何寫一個程式能將你有的點數來換獎品的獎品的所有解
> 且每個解一定要達到最後剩下的點數無法再換任何獎品
> 而且要將全部解都output出來
> 請高手幫忙啊
> 謝謝~~~~~


試試看吧.

#include<iostream.h>
#include<conio.h>
void check(long point,int temp[10],int at)
{
int temp2[10];
for (int i=0;i<10;i++)
temp2[i]=temp[i];
if ((point-3500 >= 0) && at <=0 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[0]++; check(point-3500,temp2,0); }
if (point-4500 >= 0 && at <=1 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[1]++; check(point-4500,temp2,1); }
if (point-5000 >= 0 && at <=2 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[2]++; check(point-5000,temp2,2); }
if (point-6000 >= 0 && at <=3 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[3]++; check(point-6000,temp2,3); }
if (point-6500 >= 0 && at <=4 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[4]++; check(point-6500,temp2,4); }
if (point-7000 >= 0 && at <=5 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[5]++; check(point-7000,temp2,5); }
if (point-8500 >= 0 && at <=6 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[6]++; check(point-8500,temp2,6); }
if (point-12500 >= 0 && at <=7 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[7]++; check(point-12500,temp2,7); }
if (point-18000 >= 0 && at<=8 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[8]++; check(point-18000,temp2,8); }
if (point-20000 >= 0 && at<=9 )
{
for (int i=0;i<10;i++)
temp2[i]=temp[i];
temp2[9]++; check(point-20000,temp2,9); }
else if (point <3500)
{
for (int i=0;i<10;i++)
cout<<temp2[i]<<" ";
cout<<point<<endl;
}
}

void main(void)
{
long point;
static temp[10];
clrscr();
cout<<" written by NTUST ET "<<endl
<<" Please input your point -> ";
cin>>point;
check(point,temp,0);
getch();
}
--
[1;32m※ Origin: [33m台灣科大電子站 [37m<bbs.et.ntust.edu.tw> [m
[1;31m◆ From: [36m140.118.202.159 [m

0 new messages