Matlab °æ (¾«»ªÇø)
·¢ÐÅÈË: zjliu (ÇïÌìµÄÂܲ·), ÐÅÇø: Matlab
±ê Ìâ: [ºÏ¼¯]¼ÆËãÒ»µÀ°ÂÊýÌâµÄС³ÌÐò
·¢ÐÅÕ¾: ¹þ¹¤´ó×϶¡Ïã (2003Äê04ÔÂ02ÈÕ09:23:21 ÐÇÆÚÈý), Õ¾ÄÚÐżþ
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
bage (°Ë¸ç@ÍøÊÂÈç·è@³ÕÐÄÄѶ¯) ÓÚ 2002Äê08ÔÂ16ÈÕ22:34:05 ÐÇÆÚÎå ˵µÀ:
ÓÉ1998λ1×é³ÉµÄÊýƽ·½£¬Ãݵĸ÷λÊý×ÖÖ®ºÍÊǶàÉÙ£¿
Ò»µÀСѧ°ÂÊýÌ⣬±ðÈËÎÊÎÒ£¬ÎÒ×ö²»³öÀ´£¬Ö»ºÃÓÃmatlabËãÁË
»ù±¾Ë¼Â·¾ÍÊǸù¾Ý³Ë·¨·¨Ôò£¬¼ÆËã½øλÓëºÍ
ÓÉÓÚ×î¶àÖ»ÓÐ1998¸ö1Ïà¼Ó£¬ËùÒÔ½øλֻÄܽøµ½¼ÆËãλµÄÇ°Èýλ
²»ÖªµÀ´ð°¸ÊÇ·ñÕýÈ·:)´ó¼Ò¿´¿´ÓÐʲô´íÎó
a=1:1998;
b=1997:-1:1;
c=[a b];
for n=1:3995
if(c(n)/1000>1)
c(n+3)=c(n+3)+floor(c(n)/1000); //¼ÆËãÇ°ÃæµÚÈýλµÄ½øλ
if(mod(c(n),1000)/100>1)
c(n+2)=c(n+2)+floor(mod(c(n),1000)/100); //µÚ¶þλµÄ½øλ
if(mod(c(n),100)/10>1)
c(n+1)=c(n+1)+floor(mod(c(n),100)/10); //Ç°ÃæһλÉϵĽøλ
end
end
elseif(c(n)/100>1)
c(n+2)=c(n+2)+floor(c(n)/100);
if(mod(c(n),100)/10>1)
c(n+1)=c(n+1)+floor(c(n)/10);
end
elseif(c(n)/10>1)
c(n+1)=c(n+1)+floor(c(n)/10);
end
c(n)=mod(c(n),10); //¼ÆËãλÉϵÄÊý×Ö
end
summmm=sum(c);
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
bage (°Ë¸ç@ÍøÊÂÈç·è@³ÕÐÄÄѶ¯) ÓÚ 2002Äê08ÔÂ16ÈÕ22:45:16 ÐÇÆÚÎå ˵µÀ:
ÎÒ¿´ÁË¿´¼ÆËãºóµÄ¸÷λÊý×Ö£¬Ã»·¢ÏÖʲô¹æÂÉѽ£¬ÊÇÎÒ¼ÆËã´íÁË£¿
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
Systems (Systems) ÓÚ 2002Äê08ÔÂ17ÈÕ12:23:16 ÐÇÆÚÁù ˵µÀ:
ÎÒÓÃTC2.0±àÁËÒ»¸ö³ÌÐò¡£Ëã·¨ºÍÄãµÄÂÔÓв»Í¬
´ð°¸ÊÇ17982,ÄãµÄÄØ?
/***************************************************************************
This programme is used to work out the summation of each digit of the
square of an integer containing 1998 digits, the each digit of which is one.
***************************************************************************/
# include <stdio.h>
# include <math.h>
# define LENGTH 3997 /*For easy-understanding, omit the 0th element*/
/*For the stability, one more element 3997 added*/
int main()
{
long c[LENGTH]; /*Define original sum on each digit.*/
long y[LENGTH]; /*Define the carry number.*/
long d[LENGTH]; /*Define the final number left on each digit.*/
long i = 0, j = 0;
long sum = 0; /*Define the summation.*/
/*Initialise c, d and y*/
for(i = 1; i <= 1998; i++)
{
c[i] = i;
y[i] = 0;
d[i] = 0;
}
for(i = 1999, j = 1997; i < (LENGTH - 1); i++, j--)
{
c[i] = j;
y[i] = 0;
d[i] = 0;
}
d[1] = 1; /*Initialise the starting points.*/
y[0] = 0; /*Indeed, y[0] is no use for aggregation.*/
for(i = 1; i < (LENGTH - 1); i++)
{
/*Because each digit ahead is 10 times of the current one.*/
y[i] = (c[i] + y[i - 1] - d[i])/10;
if((c[i + 1] + y[i]) >= 1000)
{
d[i + 1] = fmod(fmod(fmod((c[i + 1] + y[i]), 1000), 100), 10);
}
else if(((c[i + 1] + y[i]) >= 100) && ((c[i + 1] + y[i]) < 1000))
{
d[i + 1] = fmod(fmod((c[i + 1] + y[1]), 100), 10);
}
else if(((c[i + 1] + y[i]) < 100) && ((c[i + 1] + y[i]) >= 10))
{
d[i + 1] = fmod((c[i + 1] + y[i]), 10);
}
else
{
d[i + 1] = c[i + 1] + y[i];
}
}
/*Get the summation.*/
for(i = 1; i < (LENGTH - 1); i++)
{
sum = sum + d[i];
}
printf("\n\nThe summation is %ld\n", sum);
exit(0);
}
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
bage (°Ë¸ç@ÍøÊÂÈç·è@³ÕÐÄÄѶ¯) ÓÚ 2002Äê08ÔÂ17ÈÕ19:36:29 ÐÇÆÚÁù ˵µÀ:
ÔÀ´µÄ³ÌÐòÓÐЩÎÊÌâ:)ÉÙÁËÕûÊ®Õû°ÙÕûǧµÄ½ø룬ÕâÑùÕû¸ö¼ÆËã¾ÍÂÒÁË
Õâ´Î¸ù¾ÝutahµÄËã·¨ÓÃmatlab¼ÆËãÁËһϣ¬Õâ´Î¶ÔÁË£¬´ó¼Ò°ïæÏëÏë
ÔõôÑùÊÖ¹¤¼ÆËãѽ
a=1:1998;
b=1997:-1:1;
c=[a b];
rmod=0;
for n=1:3995
temp=c(n)+rmod;
c(n)=mod(temp,10);
rmod=floor((temp-c(n))/10);
end
summmm=sum(c);
лл¸÷λ:)
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
bage (°Ë¸ç@ÍøÊÂÈç·è@³ÕÐÄÄѶ¯) ÓÚ 2002Äê08ÔÂ17ÈÕ19:47:37 ÐÇÆÚÁù ˵µÀ:
ÎҰѼÆËãºóµÄcÏÔʾ³öÀ´ÁË£¬ÕÒ³ö¹æÂÉÁË:)
´Ó¸öλ¿ªÊ¼ÒÀ´ÎΪ
1234567890234567890234567890¡¡23456789(9Ϊ1998λÉϵÄÊý×Ö)87654321097654321
097654321¡¡097654321
(2+3+4+5+6+7+8+9)*1998/9+1+(9+7+6+5+4+3+2+1)*1998/9-1
=17982
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
ZhongNanHai (ÑàÎÞÐÄÒÔ³öᶡòѧ²¹ÐÄÊõ¡ò´óµÀÎÞÃÅ) ÓÚ 2002Äê08ÔÂ17ÈÕ19:50:54 ÐÇÆÚÁù ˵µÀ:
²»ÊÇÈÃÈË×öµÄÌâ
ÊÇÈüÆËã»ú×÷µÄÌâ
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
bage (°Ë¸ç@ÍøÊÂÈç·è@³ÕÐÄÄѶ¯) ÓÚ 2002Äê08ÔÂ17ÈÕ20:04:33 ÐÇÆÚÁù ˵µÀ:
ÆäʵÕâЩСѧ°ÂÊýÌâÈç¹ûÊܹýѵÁ·µÄСѧÉúÕæµÄÓпÉÄÜ×ö³öÀ´
Ö÷ÒªÎÒÃÇûÓÐÕâ¸öÄÍÐÄ°ÕÁË:)
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
ramjet (ʷŬ±È¹·) ÓÚ 2002Äê08ÔÂ17ÈÕ21:47:03 ÐÇÆÚÁù ˵µÀ:
%Æäʵ¿ÉÒÔÓÃ5ÐдúÂë¸ã¶¨£¬ Matlab@Lilac BBS
a=[1:1998,1998-1:-1:1]
while sum(floor(a/10))~=0
a=[floor(a/10) 0]+[0 rem(a,10)];
end
sum(a)
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
My (¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨) ÓÚ 2002Äê08ÔÂ18ÈÕ21:51:24 ÐÇÆÚÌì ˵µÀ:
СѧʱºòÊýѧ°à½²111111111111111111111111(Èô¸É)¼ÆËãÊÇÓйæÂɵÄ
¾ßÌåµÄÍü¼ÇÁË
µ«ÊǴӳ˷¨¹«Ê½ÍÆËãÊÇ¿ÉÒÔÕÒ³ö1234567890-234567890...µÄ¹æÂɵÄ
hehe
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
Systems (Systems) ÓÚ 2002Äê08ÔÂ18ÈÕ22:13:57 ÐÇÆÚÌì ˵µÀ:
¸æËßСÅóÓÑÏ´ξºÈü´ø¸öDSPÈ¥,ÏÖ³¡±à³Ì¼ÆËã
©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤©¤
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
Ò³ÃæÖ´ÐÐʱ¼ä£º3.721ºÁÃë