版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
6001題:求出[1000,100000]內(nèi)所有能同時被17和19整除的整數(shù)之和。原程序:#include<iostream.h>#include<math.h>classaddition(longi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longal,longbl,longcl,longdl){a=al;b=b1;c=cl;d=d1;}voidsolution(){fbr(i=a;i<=b;i++)if(){sum=sum+i;voidadd_sum()cout?"sumis:"?sum?endl;);voidmain(){additionobj(1000,10000,17,19);obj.solution();obj.add_sum();}答案:1482576002題:求出[1000,100000]內(nèi)所有能同時被17和19整除的整數(shù)的個數(shù)。原程序:#include<iostream.h>#include<math.h>classadditionlongi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longa1Jongb1Jongcl,longdl){a=a1;b=b1;c=cl;d=d1;}voidsolution(){fbr(i=a;i<=b;i++)if()count++;}voidadd_number()(cout?"Thenumberis:"?count?endl;}};voidmain()(additionobj(1000,10000,17,19);obj.solution();obj.add_number();6003題:求出[1000,10000]內(nèi)所有能被147或者197整除的整數(shù)中最大值與最小值之差。原程序:#include<iostream.h>#include<math.h>classaddition(longi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longal,longbl,longcl,longdl){a=al;b=b1;c=cl;d=d1;}voidsolution(){sum=0;count=0;max=0;min=b;fbr(i=a;i<=b;i++)if((i%c=0&&i%d!=0)ll(i%c!=0&&i%d==0)){sum=sum+i;count++;if(i<min) if(i>max) voidsub_abs()cout?"Thesubabsolutionis:"?max-min?endl;}};voidmain()(additionobj(1000,10000,147,197);obj.solution();obj.sub_abs();)答案:89676004題:求出[1000,10000]內(nèi)所有能被147或者197整除的整數(shù)的個數(shù)。原程序:#include<iostream.h>#include<math.h>classadditionlongi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longal,longbl,longcl,longdl){a=al;b=b1;c=cl;d=d1;}voidsolution(){fbr(i=a;i<=b;i++)if((i%c==0&&i%d!=0)ll(i%c!=0&&i%d==0))}voidadd_number()(cout?"Thenumberis:"?count?endl;}};voidmain()(additionobj(1000,10000,147,197);obj.solution();obj.add_number();6005題:求出[1000,10000]內(nèi)所有能被147或者197整除的整數(shù)的之和。原程序:#include<iostream.h>#include<math.h>classaddition(longi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longal,longbl,longcl,longdl){a=al;b=b1;c=cl;d=d1;}voidsolution(){fbr(i=a;i<=b;i++)if()sum=sum+i;)voidadd_sum()cout?"sumis:"?sum?endl;};voidmain()(additionobj(1000,10000,147,197);obj.solution();obj.add_sum();}答案:5899956006題:求整數(shù)4998889的因子(不包括1和自身)中的最小者。原程序:#include<iostream.h>#include<math.h>classfactorial(intn,count,max,min,sum;public:factorial(intm){n=m;}voidsolution()inti;for(i=2;i<n;i++)if(){if(min>i)min=i;}}voidshow(){solution();cout?"min="?min?endl;}};voidmain()(factorialob(4998889);ob.show();)答案:76007題:個位數(shù)為6,且能被3整除的所有五位數(shù)(最高位非0)的和。原程序:#include<iostream.h>#include<math.h>classnumberdivide3(private:longi,m,sum,max,min;public:numberdivide3(longml){i=0;m=ml;)voidsolution();voidshow_sum(){cout?"sum="?sum?endl;}};voidnumberdivide3::solution()while(m<100000)if()sum=sum+m;m+=10;}}voidmain()(numberdivide3ob(10006);ob.solution();ob.show_sum();}答案:165033006008題:編寫一個程序,求數(shù)30240和62280共同擁有的因子之和(不包括1)。原程序:#include<iostream.h>#include<math.h>classsimpleintx,y,sum;public:simple(intfenzi,intfenmu){x=fenzi;y=fenmu;}voidsolution(){inti,n;sum=0;if()n=y;elsen=x;for(i=2;i<=n;i++)if(x%i==0&&y%i==0)}voidshow_sum(){cout?"sum="?sum?endl;}};voidmain()(simpleob(30240,62280);ob.solution();ob.show_sum();答案:11696009題:求個位數(shù)為6,且能被3整除的五位數(shù)(最高位非0)中最大數(shù)加上最小數(shù)的值。原程序:#include<iostream.h>classnumberdivide3(private:longi,m,max,min;public:numberdivide3(longml){i=0;m=ml;}voidsolution();voidshow_abs_add(){cout?"max+min="?max+min?endl;});voidnumberdivide3::solution()max=0;min=99999;while(m<100000){if()(if(max<m)max=m;if(min>m)min=m;)m+=10;))voidmain()(numberdivide3ob.solution();ob.show_abs_add();)答案:1100226010題:求整數(shù)4998889的因子(不包括1和自身)中的最大值與最小值之和。原程序:#include<iostream.h>#include<math.h>classfactorial(intn,count,max,min,sum;public:factorial(intm){n=m;count=0;max=0;;sum=0;}voidsolution(){inti;for(i=2;i<n;i++)if(){if(max<i)max=i;if(min>i)min=i;}}voidshow(){solution();cout?"max+min="?max+min?endl;};voidmain(){factorialob(4998889);ob.show();}答案:7141346011題:編寫一個程序,求數(shù)30240和62280共同擁有的因子個數(shù)(不包括1)中最大值與最小值之和。原程序:#include<iostream.h>#include<math.h>classsimple(intx,y,max,min;public:simple(intfienzi,intfenmu){x=fenzi;y=fenmu;}voidsolution(){inti,n;max=0;;if(x>y)n=y;elsen=x;for(i=2;i<=n;i++)if()(if(max<i)max=i;if(min>i)min=i;}}voidshow_abs_add(){cout?"max4-min="?max+min?endl;}};voidmain()(simpleob(30240,62280);ob.solution();ob.show_abs_add();答案:11696012題:編寫一個程序,求數(shù)30240和62280共同擁有的因子(不包括1)中的最大值。原程序:#include<iostream.h>#include<math.h>classsimple(intx,y,max;public:simple(intfienzi,intfenmu){x=fenzi;y=fenmu;}voidsolution(){inti,n;max=0;if()n=y;elsen=x;for(i=2;i<=n;i++)if(x%i==O&&y%i==O)if()max=i;}voidshow_max(){cout?"max="?max?endl;}};voidmain()(simpleob(30240,62280);ob.solutionO;ob.show_max();)答案:3606013題:個位數(shù)為6,且能被3整除的五位數(shù)(最高位非0)中,最大數(shù)減去最小數(shù)的值。原程序:#include<iostream.h>#include<math.h>classnumberdivide3{private:longi,m,max,min;public:numberdivide3(longml){i=0;m=ml;)voidsolution();voidshow_abs_sub(){cout?"max-min="?max-min?endl;}};voidnumberdivide3::solution()(max=0;min=99999;while(m<100000)(if()m+=10;})voidmain()(numberdivide3;ob.solution();ob.show_abs_sub();)答案;899706014題:求整數(shù)4998889的因子中最大與最小值之差。原程序:#include<iostream.h>#include<math.h>classfactorialintn,max,min;public:factorial(intm){n=m;max=O;min=m;}voidsolution()(inti;for(i=2;i<n;i++)if(n%i==0){if(max<i)max=i;if(min>i)min=i;}}voidshow(){cout?"max-min="?max-min?endl;});voidmain()(factorial;ob.show();答案:7141206015題:求1000—2000之間,能被13除余11,被29除余17,被37除余31,求該數(shù)。原程序:#include<iostream.h>voidmain(){for()if()cout?i?endl;}答案:18446016題:個位數(shù)為6,且能被3整除的五位數(shù)(最高位非0)共有多少個?。原程序:#include<iostream.h>#include<math.h>classnumberdivide3{private:longi,m,sum,max,min;public:numberdivide3(longml){i=0;m=ml;)voidsolution();voidshow_num(){cout?"number="?i?endl;});voidnumberdivide3::solution()(sum=0;max=0;;while(m<100000)if(m/3*3==m)i++;voidmain()numberdivide3ob(l0006);ob.solution();ob.show_num();}答案:30006017題:求整數(shù)4998889的因子個數(shù)的程序(不包括1和自身)。原程序:#include<iostream.h>#include<math.h>classfactorial(intn,count,max,min,sum;public:factorial(intm){n=m;count=0;}voidsolution()inti;for(i=2;i<n;i++)if()count++;}voidshow(){cout?"count="?count?endl;)};voidmain()(factorialob(4998889);ob.show();}答案:146018題:求整數(shù)4998889的因子(不包括1和自身)的和。原程序:#include<iostream.h>classfactorialsum{intn,sum;public:factorialsum(intm){n=m;sum=0;}voidsolution()(inti;for(i=2;i<n;i++)if(n%i==0) }voidshow(){solution();cout?"factorialsummary="?sum?endl;});voidmain()(factorialsum;ob.show();答案:10721506019題:將小于2000且能被4和6中至少一個數(shù)整除的所有整數(shù)按從小到大順序排列后,求最后面的20個數(shù)之和。原程序:#include<iostream.h>classadd_sum(intx,j,m,n,i,k,sum;public:add_sum(intjl,intml,intkl,intnl){j=j1;m=ml;k=kl,n=nl;}voidback_sum(){i=0;sum=0;x=j;while(i<n&&x>0){x=x-l;if(){sum=sum+x;if(x>=O&&i==n)cout?"Thesumis:"?sum?endl;)};voidmain()(add_sumobj(2000,4,6,20);obj.back_sum();)答案;393906020題:將大于1000且能被3和5中至少一個數(shù)整除的所有整數(shù)按從小到大順序排列后,求最前面的20個數(shù)之和。原程序:#include<iostream.h>classadd_sumintx,j,m,n,i,k,sum;public:add_sum(intjl,intml,intkl,intn1){j=j1;m=m1;k=k1,n=n1;}voidpre_sum()(i=0;sum=0;x=j;while(){x=x+1;if(x%m==0llx%k==0){i=i+l;}}if(x>=j&&i==n)cout?"Thesumis:"?sum?endl;}};voidmain()(add_sumobj(1000,3,5,20);obj.pre_sum();答案:204656021題:求數(shù)29516和464172的最大公約數(shù)t并輸出。原程序:#include<iostream.h>classeuclidean(private:intnl,n2;public:euclidean(intml,intm2){nl=ml;n2=m2;}voidcalculate()(inttemp;if(){temp=n2;n2=n1;n1=temp;}while(nl>0)n2=nl;nl=temp;cout?n2?endl;}};voidmain()(euclideanob(29516,464172);ob.calculate();}答案:1886022題:編寫一個程序,求數(shù)30240和62280共同擁有的因子個數(shù)(不包括1)。原程序:#include<iostream.h>#include<math.h>classsimpleintx,y,count;public:simple(intfenzi,intfenmu){x=fenzi;y=fenmu;count=0;}voidsolution(){inti,n;if()n=y;elsen=x;for(i=2;i<=n;i++)if(x%i==0&&y%i==0)count++;}voidshow_num(){cout?"number="?count?endl;}};voidmain()(simpleob(30240,62280);ob.show_num();答案:236023題:輸入x=0.5值(lxl<l),按下列公式計算S:S=x+x*x/2+x*x*x/3+x*x*x*x/4+ ,直到最后一項的絕對值小于10-5時為止(按四舍五入保留到6位小數(shù))。原程序:#include<iostream.h>#include<stdlib.h>#include<math.h>voidmain()(doublex,temp,s;inti=2;cout?"inputx=";cin?x;if(fabs(x)>l){cout?"xisgreat1,exit!"?endl;exit(1);}while()temp=temp*x;s=s+temp/i;i++;}cout?s?endl;)答案:0.6931396024題:+n*n<10000o求滿足以下條件的最大的n:l*l+2*2+3*3M*4+n*n<10000o原程序:#include<iostream.h>intfunc(int,int);voidmain()(cout?"n="?func(0,0);cout?endl;intfunc(intn,ints)intnl,sl;if(sl<=10000){nl=n+l;elsereturnn-1;}答案:306025題:編程求算式:n+n*n+n*n*n+n*n*n*n+.…的前10項之和。其中n=4。原程序:#include<iostream.h>classnpowersum{private:ints,n;public:npowersum(intm=2){;s=0;}intfunc();voidshow(){cout?"sum="?func()?endl;}};intnpowersum::func()(fbr(inti=0;i<=10;i++)returns;}voidmain(){npowersumob(4);ob.show();}答案:55924046026題:當(dāng) x=0.5 時, 計 算arctg(x)=x-x*x*x/3+x*x*x*x*x/5-x*x*x*x*x*x*x/7+ 的值。當(dāng)計算到最后一項的絕對值小于10E-5時為止(精確到小數(shù)點后6位)。原程序:#include<iostream.h>voidmain()(doublex,item,sum;inti=3,k=l;cout?"pleaseinputx:";cin?x;sum=x;item=x;do{k=-k;sum=sum+item;i=i+2;}while();cout?sum?endl;答案:0.4583336027題:編寫一程序,求數(shù)列1,-3!,5!,-7!,…,前5項的和。原程序:#include<iostream.h>classsum(private:intsign,n;floatsuml;public:sum(){sign=1;sum1=0.0;cout?"pleaseinputvalueofn:";cin?n;}floatadd();voidshow(){cout?"sum="?add()?endl;}};floatsum::add()(inti,j;floatfac;for(i=l;i<=2*n-l;i=i+2)fac=1.0;for(j=l;j<=i;j++)sum1=sum1+sign*fac;returnsuml;}voidmain(){sumob;ob.show();}答案:3579556028題:求n=100個三角堆的總核數(shù)。即s=1=(1+2)+(1+2+3)+(1+2+3+4)++(1+2+3+ +n) o原程序:#include<iostream.h>classtrisum(private:intn,sum;public:trisum(intm){n=m;;}voidsummary(){inti,j;for(i=l;i<=n;i++)sum=sum+j;cout?sum?endl;));voidmain(){trisumob(l00);ob.summaryO;答案:1717006029題:求Sn=l-l/2+l/3-l/4+……前30項之和(按四舍五入保留四位小數(shù))。原程序:#include<iostream.h>#include<math.h>classsummary(private:intn;public:doublesum(){doublesum=0.0;intk=-l,kk=-l;for(n=1;n<=30;n++)returnsum;);voidmain()summaryob;cout?ob.sum()?endl;)答案:0.67686030題:編寫一個程序,計算從1到100的所有整數(shù)n的立方和,當(dāng)和大于10000000時結(jié)束,輸出整數(shù)n的值。原程序:#include<iostream.h>classcubesum{private:longsum;public:cubesumO{}voidsumary()inti;for(i=l;i<=100;i++){sum=sum+i*i*i;if(sum>10000000) }cout?i?endl;});voidmain(){cubesumob;ob.sumary();}答案:806031題:數(shù)列:0,1,3,8,21,……,問第70個數(shù)被6除余幾?原程序:#include<iostream.h>voidmain()(inta[70]={0,l,3,8,21);inti,x;for(i=2;i<69;i++)cout??endl;}答案:46032題:求下列分?jǐn)?shù)序列1/2,3/2,5/3,8/5,13/8,21/13, 的和,當(dāng)和大于21.8時結(jié)束,輸出該序列的項數(shù)。原程序:#include<iostream.h>voidmain()(inti=1,m=3,n=2,k,count=1;doubles=0.5;dos=s+(double)m/n;k=n;count++;}while(s<21.8);cout?count?endl;}答案:156033題:求數(shù)歹U a0,al,a2, 中 a20的值。已知 :a0=0,al=l,a2=l,a3=al+2*al+a2,a4=al+2*a2+a3 ,a4=a2+2*a3+a4,…。原程序:#include<iostream.h>voidmain()(inti,a[101]={0,l,l,4};for()cout?a[20]?endl;答案:計算1+1/1!+1/2!+1/3!+1/4!+ 的值。計算到最后一項小于10E-6時為止((按四舍五入保留6位小數(shù))。原程序:#include<iostream>usingnamespacestd;voidmain()(inti=l,n=l;doublesum=1.0;doi++;}while(1.0/n>le-6);cout?sum?endl;}答案:2.718286035題:已知第一個數(shù)為10,其余數(shù)一個比一個大2n-l,求前8個數(shù)的之和。原程序:#include<iostream.h>classaddage(private:intn;public:addage(intm){n=m;}intage(intn);voidshow_sum_age(){inti,sum=0;fbr(i=l;i<=8;i++)sum=sum+age(i);cout?"ThesumofAgeis:"?sum?endl;}};intaddage::age(intn)(intc;if()c=10;elsereturnc;}voidmain(){addageob(8);ob.show_sum_age();}答案:2766036題:數(shù)列1,1,2,3,5,8,13,21,……是著名的菲波那奇數(shù)列,求前30項的和與前20項和的差。原程序:#include<iostream.h>classseveral(private:longa,b,suml0,sum20;intn;public:longseveralsolution(intm);longsum(intm);voidshow_suml0_sum20()(cout?"sum30-sum20="?sum(30)-sum(20)?endl;}};longseveral::severalsolution(intm)(longitem;inti;if(i==llli==2){a=l;b=l;item=l;}elsea=b;b=item;}}returnitem;}longseveral::sum(intm)(inti,temp=0;for(i=l;i<=m;i++)returntemp;}voidmain(){severalob;ob.show_sum10_sum20();答案:21605986037題:數(shù)列1,1,2,3,5,8,13,21,……是著名的菲波那奇數(shù)列,求項值剛好大于20000的項數(shù)n是多少。原程序:#include<iostream.h>classseveral{private:longa,b;intn;public:longseveralsolution(intm);voidshow_itemn(){n=l;while(severalsolution(n)<=20000)cout?"item_n="?n?endl;)};longseveral::severalsolution(intm)longitem;inti;fbr(i=l;i<=m;i++)(if(){a=l;b=l;item=l;}else{item=a+b;a=b;b=item;})returnitem;)voidmain()(severalob;ob.show_itemn();)答案:236038題:數(shù)列1,1,2,3,5,8,13,21,……是著名的菲波那奇數(shù)列,求和到多少項時和大于20000o原程序:#include<iostream.h>classseveral(private:longa,b;intn;public:longseveralsolution(intm);longsum(intm);voidshow_sumn(){n=l;while()n++;cout?"sum_n="?n?endl;});longseveral::severalsolution(intm)(longitem;inti;for(i=l;i<=m;i++)if(i==llli==2){a=l;b=l;item=l;}else{item=a+b;a=b;b=item;}}returnitem;}longseveral::sum(intm)(inti,;for(i=l;i<=m;i++)temp=temp+severalsolution(i);returntemp;}voidmain()(severalob;ob.show_sumn();答案:21數(shù)列1,1,2,3,5,8,13,21,……是著名的菲波那奇數(shù)列,求前30項的和。原程序:#include<iostream.h>classseveral(private:longa,b,suml0,sum20;intn;public:longseveralsolution(intm);longsum(intm);voidshow_sum30(){cout?"sum30="??endl;}};longseveral::severalsolution(intm)(longitem;inti;if(i==llli==2){a=l;b=l;item=l;}else{item=a+b;a=b;b=item;})returnitem;}longseveral::sum(intm)(inti,temp=0;for(i=l;i<=m;i++)returntemp;)voidmain()(severalob;ob.show_sum30();有一分?jǐn)?shù)序2/1,3/2,5/3,8/5,13/8,21/13,……,試編制程序求出這個數(shù)列的前n項之和(精確到小數(shù)點后4位)。原程序:#include<iostream.h>classsequence(private:intnumber;floata,b,s;public:sequence(intn){number=n;a=2;b=1;s=0;}floatsum();};floatsequence::sum(){inti;floatt;fbr(i=l;i<=number;i++);t=a;;b=t;}returns;}voidmain()(intn;cout?"Pleaseinputitemnumber:";cin?n;sequenceseq(n);cout?"sum="?seq.sum()?endl;}答案:32.66036041題:已知第一個數(shù)為為10,其余每個數(shù)一個比一個大2*n-l,求第30個數(shù)的值。原程序:#include<iostream.h>classaddageprivate:intn;public:addage(intm){n=m;}intage(intn);voidshow_age(){cout?"Age="?age(n)?endl;}};intaddage::age(intn)(intc;if(n==l)elsereturnc;}voidmain()(addageob(30);ob.show_age();答案:736042題:求滿足下列不等式的n的值:1+1/2+1/3+1/4+……+l/n>3.8o原程序:#include<iostream.h>classadditem{private:doublesum,value;intn;public:additem(doublem){sum=0.0;value=m;n=0;}intitem();voidshow(){cout?"itemnumber="?item()?endl;}};intadditem::item()do++n;}while();returnn;)voidmain()(additemob(3.8);ob.show();}答案:256043題:編寫程序,求一正整數(shù)等差數(shù)列的前50項的和,該數(shù)列前四項之和是26,四項之積是880。原程序:#include<iostream.h>classaddsumprivate:intsuml,n;public:addsum(intm){suml=O;n=m;}intsum();voidshow(){cout?"sum="?sum()?endl;}};intaddsum::sum(){inta,b,c,d,i;for(a=1;a<=26;a++)for(d=l;d<=26;d++){b=a+(a+d)+(a+2*d)+(a+3*d);if(b!=26)continue;else{c=a*(a+d)*(a+2*d)*(a+3*d);if()continue;elsefor(i=0;i<50;i++)returnsuml;voidmain()addsumob(50);ob.show();}答案:37756044題:數(shù)列1,1,2,3,5,8,13,21,……是著名的菲波那奇數(shù)列,求第28項的值。原程序:#include<iostream.h>classseveral(private:longa,b;intn;public:longseveralsolution(intm);voidshow_item(){cout?"item28="??endl;});longseveral::severalsolution(intm){longitem;inti;for(i=l;i<=m;i++)(if(i==llli==2){a=l;b=l;item=l;}else{;a=b;b=item;}}returnitem;}voidmain()(severalob;ob.show_item();答案:3178116045題:寫一個函數(shù),求不大于10000的整數(shù)各位數(shù)字之和為9的數(shù)據(jù)個數(shù)。原程序:#include<iostream.h>classsum9(public:intsum_9();voidshowsum(){cout?sum_9()?endl;}};intsum9::sum_9(){intx[5],n,j,sum=0;for(n=0;n<10000;n++)(inti;i=n;for()if(x[0]+x[l]+x[2]+x[3]+x[4]==9)sum++;}returnsum;}voidmain()(sum9ob;ob.showsum();)答案;2206046題:求方程3x-5y=l在條件IxklOO且lyl<40下的所有整數(shù)解的Ixl+lyl的最小值。原程序:#include<iostream.h>#include<math.h>voidmain()intx,y,absxy;for(x=-99;x<100;x++)for(y=-39;y<40;y++)if()absxy=abs(x)+abs(y);cout?absxy?endl;答案:36047題:求解世界上的有名的“百雞問題":雞翁一,值錢五,雞母一,值錢三,雞鄒三,值錢一。百錢買百雞,問雞翁、雞母和雞鄒各幾何?寫出當(dāng)雞翁為8時,雞母有幾只?原程序:#include<iostream.h>voidmain()inti,j,k,sum,rsum;for(i=0;i<=100;i++)for(j=0;j<=100;j++)for(k=0;k<=100;k++){sum=i+j+k;if()cout<<i?","?j?","?k?endl;}}答案:116048題:求方程9x+4y=1000的所有正整數(shù)解的Ix-yl的最大值。原程序:#include<iostream.h>#include<math.h>voidmain()intx,y,absxy;for(x=l;x<l000;x++)for(y=1;y<l000;y++)if()absxy=abs(x-y);cout?absxy?endl;}答案:2376049題:有一個年份數(shù),它與由它的數(shù)字倒排所成的數(shù)的和為8657,已知它的最后兩位數(shù)字相等且年份的最高位不為0,求該年份。原程序:#include<iostream.h>voidmain(){inti,j,k;用r()for(j=0;j<10;j++)for(k=0;k<10;k++)if()cout?i?j?k?k?endl;}答案:19666050題:求積為50400的連續(xù)整數(shù)(它本身除外),即連續(xù)若干個整數(shù)之積為50400,輸出連續(xù)整數(shù)中最小的整數(shù)。原程序:#include<iostream.h>#definen50400voidmain()(fbr(longi=l;i<n;i++)(longj=i,m_sum=l;if()fbr(longk=i;k<=j-l;k++)cout?k?"cout?endl;}})答案:2246051題:求方程3x-7y=l在條件IxIclOO且lyl<40下的所有整數(shù)解的Ixl+lyl的最大值。原程序:#include<iostream.h>#include<math.h>voidmain(){intx,y,absxy;for(x=-99;x<100;x++)for(y=-39;y<40;y++)if(()absxy=abs(x)+abs(y);cout?absxy?endl;}答案:1276052題:求方程8372*xA2-33488*x=1850212在范圍[-1000,+1000]之間的整數(shù)解,請輸出解的絕對值之差的絕對值。原程序:#include<iostream.h>#include<math.h>classequation(longa,b,c,d,e,x,xs[3],solution_count;public:equation(longal,longb1Jongc1Jongd1Jongel){a=a1;b=b1;c=c1;d=d1;e=e1;}voidsolution(){for(x=d;x<=e;x++)if(a*x*x+b*x==c)xs[++solution_count]=x;}voidsolution_abs_sub()〃絕對值的差的絕對值{switch()(case 1:cout?"solution abs subis:"?abs(xs[solution_count])?endl;break;case 2:cout?"solution abs subis:"?abs(abs(xs[l])-abs(xs[2]))?endl;break;default:cout?"Notsolution!"?endl;break;}}};voidmain()(equationobj(8372,-33488,1850212,-1000,+1000);obj.solution();obj.solution_abs_sub();答案:46053題:求方程8372*x*x-33488*x=l850212在范圍[-1000,+1000]之間的整數(shù)解,請輸出解的個數(shù)。原程序:#include<iostream.h>#include<math.h>classequation{longa,b,c,d,e,x,xs[3],solution_count;public:equation(longal,longb1,longcl,longdl,longel){a=al;b=b1;c=c1;d=dl;e=e1;}voidsolution(){for(x=d;x<=e;x++)if(a*x*x+b*x==c)xs[]=x;voidsolution_number()cout?"solutionnumberis:"?solution_count?endl;);voidmain()(equationobj(8372,-33488,1850212,-1000,+1000);obj.solution();obj.solution_number();}答案:26054題:求方程9x+4y=1000的所有正整數(shù)解的Ix-yl的最小值。原程序:#include<iostream.h>#include<math.h>voidmain()intx,y,absxy;for(x=l;x<l000;x++)for(y=1;y<l000;y++)if()absxy=abs(x-y);cout?absxy?endl;}答案:36055題:求方程9x+4y=1000的所有正整數(shù)解的Ix-yl的個數(shù)。原程序:#include<iostream.h>voidmain()(intx,y,count;for()for(y=l;y<1000;y++)if(9*x+4*y==1000)count++;cout?count?endl;答案:276056題:求方程8372*x*x-33488*x=1850212在范圍[-1000,+1000]之間的整數(shù)解,請輸出解的絕對值之和。原程序:#include<iostream.h>#include<math.h>classequation(longa,b,c,d,e,x,xs[3],solution_count;public:equation(longal,longbl,longc1,longdl,longel){a=al;b=b1;c=cl;d=dl;e=e1;}voidsolution(){solution_count=0;fbr(x=d;x<=e;x++)if(a*x*x+b*x==c) voidsolution_abs_add()switch(solution_count){cout?"solutionabsaddis:"?abs(xs[solution_count])?endl;break;cout?"solutionabsaddis:"?(abs(xs[1])+abs(xs[2]))?endl;break;default:cout?"Notsolution!"?endl;break;)}};voidmain()(equationobj(8372,-33488,1850212,-1000,+1000);obj.solution_abs_add();答案:306057題:兩個整數(shù)100與10000之間有多少整數(shù)其數(shù)字之和等于5?原程序:#include<iostream.h>#include<iomanip.h>classnumber5(private:intkl,k2,k3,k4,n;public:number5(){n=0;}voidsolution();voidshow(){solution();cout?"n="?n?endl;});voidnumber5::solution()inti;for(i=100;i<10000;i++)k3=i/100%10;k4=i/1000%10;if(kl+k2+k3+k4==5)n++;}}voidmain()(number5ob;ob.show();}答案:506058題:求方程8372*x*x-33488*x=l850212在范圍[-1000,+1000]之間的整數(shù)解,請輸出解的最小值。原程序:#include<iostream.h>#include<math.h>classequation{longa,b,c,d,e,x,xs[3],solution_count;public:equation(longaI,longbl,longc1,longdl,longel){a=a1;b=b1;c=cl;d=d1;e=e1;}voidsolution(){solution_count=0;for(x=d;x<=e;x++)if(a*x*x+b*x==c)xs[++solution_count]=x;}voidsolution_min()(switch(){cout?"solutionminis:"?xs[solution_count]?endl;break;cout?"solutionminis:"??endl;break;default:cout?"Notsolution!"?endl;break;);voidmain()(equationobj(8372,-33488,1850212,-1000,+1000);obj.solution();obj.solution_min();}答案:-136059題:求出[1000,100000]內(nèi)所有能同時被17和19整除的整數(shù)最大值與最小值差的絕對值。原程序:#include<iostream.h>#include<math.h>classadditionlongi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longal,longbl,longcl,longdl){a=a1;b=b1;c=c1;d=d1;}voidsolution(){max=0;min=b;for(i=a;i<=b;i++)if((i%c==0)&&(i%d==0)){if(i<min) if(i>max) }}voidsub_abs()(cout?"Thesubabsolutionis:"?abs(max-min)?endl;});voidmain()(additionobj(1000,10000,17,19);obj.solution();obj.sub_abs();答案:83986060題:求方程8372*x*x-33488*x=l850212在范圍[-1000,+1000]之間的整數(shù)解,請輸出解的差的絕對值。原程序:#include<iostream.h>#include<math.h>classequation(longa,b,c,d,e,x,xs[3],solution_count;public:equation(longal,longb1Jongc1Jongd1Jongel){a=a1;b=b1;c=cl;d=dl;e=e1;}voidsolution(){solution_count=0;fbr(x=d;x<=e;x++)if(a*x*x+b*x==c)xs[]=x;}voidsolution_sub_abs(){switch(solution_count)(cout?"solutionsubabsis:"?abs(xs[solution_count])?endl;break;cout?"solutionsubabsis:"??endl;break;default:cout?"Notsolution!"?endl;break;}}};voidmain()(equationobj(8372,-33488,1850212,-1000,4-1000);obj.solution();obj.solution_sub_abs();答案:306061題:求方程8372*x*x-33488*x=l850212在范圍[-1000,+1000]之間的整數(shù)解,請輸出解的和的絕對值。原程序:#include<iostream.h>#include<math.h>classequation(longa,b,c,d,e,x,xs[3],solution_count;public:equation(longal,longbl,longc1,longdl,longel){a=a1;b=b1;c=c1;d=dl;e=e1;}voidsolution(){for(x=d;x<=e;x++)if(a*x*x+b*x==c)xs[++solution_count]=x;voidsolution_add_abs()switch(solution_count)cout?"solutionaddabsis:"?abs(xs[solution_count])?endl;break;cout?"solutionaddabsis:"?abs(xs[l]+xs[2])?endl;break;default:cout?"Notsolution!"?endl;break;}}};voidmain(){equationobj(8372,-33488,1850212,-1000,+1000);obj.solution_add_abs();}答案:46062題:求出[1000,100000]內(nèi)所有能同時被17和19整除的整數(shù)中的最大值。原程序:#include<iostream.h>#include<math.h>classaddition(longi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longal,longbl,longcl,longdl){a=al;b=b1;c=cl;d=d1;}voidsolution(){max=0;for(i=a;i<=b;i++)if((i%c==0)&&(i%d==0)){if(i<min)min=i;if(i>max)max=i;)}voidadd_max()cout?"Themaxis:"?max?endl;);voidmain(){additionobj(1000,10000,17,19);obj.add_max();}答案:96906063題:求方程8372*x*x-33488*x=1850212在范圍[-1000,+1000]之間的整數(shù)解,請輸出解的最大值。原程序:#include<iostream.h>#include<math.h>classequationlonga,b,c,d,e,x,xs[3],solution_count;public:equation(longal,longbl,longc1,longdl,longel){a=a1;b=b1;c=cl;d=dl;e=e1;}voidsolution(){fbr(x=d;x<=e;x++)if(a*x*x+b*x==c)xs[++solution_count]=x;}voidsolution_max(){switch(solution_count){case1:cout?"solutionmaxis:"?xs[solution_count];break;maxcase 2:cout?"solutionmaxis:"?((xs[1]>=xs[2])?xs[1]:xs[2])?endl;break;default:cout?"Notsolution!"?endl;break;}});voidmain()equationobj(8372,-33488,1850212,-1000,+1000);obj.solution_max();答案:176064題:ONE*ONE=TWO算式中,不同的字母代表十進(jìn)制中不同的一個數(shù)字,請問滿足該算式的解有多少?原程序:#include<iostream.h>voidmain()(inti,j,k,h,n,x,count;for(i=0;i<10;i++)for(j=0;j<10;j++)for(k=0;k<10;k++)(x=i*100+j*10+k;for(h=0;h<10;h++)for(n=0;n<10;n++)if()count++;}cout?count?endl;)答案:46065題:某數(shù)的17倍加上另一個數(shù)的19倍等于35587,兩數(shù)均在10000以內(nèi),且不為0,求滿足上述條件的解有多少個(不計重復(fù)的)?若將每對數(shù)相加,請求出這些和中最大數(shù)與最小差的絕對值。原程序:#include<iostream.h>#include<math.h>classmultiply{private:intn,count,max,min;public:voidnumber()inti,j;max=O; for(i=l;i<10000;i++)for()if(i*17+j*19==35587)(if(max<i+j)max=i+j;if(min>i+j)min=i+j;}cout?"abs(max-min)="?abs(max-min)?endl;});voidmain()(multiplyob;ob.number();)答案:1026066題:求出[500,2000]內(nèi)所有既不能被5整除也不能被7的整數(shù)中的最大值。原程序:#include<iostream.h>#include<math.h>classaddition(longi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longa1Jongb1Jongcl,longdl){a=al;b=b1;c=cl;d=d1;}voidsolution(){fbr(i=a;i<=b;i++)if()if(i>max)max=i;)voidadd_max()cout?"Themaxis:"?max?endl;};voidmain()(additionobj(500,2000,5,7);obj.solution();obj.add_max();}答案:19996067題:某數(shù)的17倍加上另一個數(shù)的19倍等于35587,兩數(shù)均在10000以內(nèi),且不為0,求滿足上述條件的解有多少個(不計重復(fù)的)?若將每對數(shù)相加,請求出最大的數(shù)。原程序:#include<iostream.h>#include<math.h>classmultiplyprivate:intn,count,max,min;public:voidnumber(){inti,j;max=0;for(i=l;i<10000;i++)for()//if(i*17+j*19==35587)(if()max=i+j;}cout?"max="?max?endl;)};voidmain()(multiplyob;ob.number();答案:19776068題:求出[1234,2346]內(nèi)恰好有兩位數(shù)字是6的所有整數(shù)的個數(shù)。原程序:#include<iostream.h>classinteger(intm,n,k,sum,count,x[4];public:integer(intml,intnl,intkl){m=ml,n=nl;k=k1;}voidsolution()(inti,j,h,y;count=0;for(i=m;i<=n;i++){y=i;h=O;x[3]=y%10;y=(y-x[3])/l0;x[2]=y%10;y=(y-x[2])/10;x[l]=y%10;y=(y-x[l])/10;for(j=0;j<4;j+4-)if(x[j]==k)h++;if()count++;})voiddisp_number()(cout?"Theresultis:"?count?endl;;});voidmain(){integerobj(l234,2346,6);obj.solution();obj.disp_number();}答案:286069題:某數(shù)的17倍加上另一個數(shù)的19倍等于35587,兩數(shù)均在10000以內(nèi),且不為0,若將每對數(shù)相加,請求出這些和數(shù)中的最小的數(shù)。原程序:#include<iostream.h>#include<math.h>classmultiply(private:intn,min;public:voidnumber()(inti,j;for(i=l;i<10000;i++)for(j=i+l;j<l0000;j++)if(i*17+j*19=35587)if()min=i+j;cout?"min="?min?endl;)};voidmain()multiplyob;ob.number();}答案:18756070題:求出[500,2000]內(nèi)所有既不能被5整除也不能被7的整數(shù)之和。原程序:#include<iostream.h>#include<math.h>classaddition(longi,a,b,c,d,sum;public:addition(longal,longbl,longcl,longdl){a=a1;b=b1;c=cl;d=d1;}voidsolution(){fbr(i=a;i<=b;i++)if()sum=sum+i;}voidadd_sum(){cout?"sumis:"?sum?endl;}};voidmain()(additionobj(500,2000,5,7);obj.solution();obj.add_sum();}答案:12867876071題:有十進(jìn)制數(shù)字a,b,c,d,e,>a、b、c、d互不相等,求滿足下列式子:abcd*e=dcba的abed的個數(shù)。原程序:#include<iostream.h>#include<math.h>voidmain()(inta,b,c,e,d,x,y,z,;fbr(a=0;a<=9;a++)for(b=0;b<=9;b++)for(c=0;c<=9;c+4-)for(d=0;d<=9;d++)for(e=0;e<=9;e++)(x=a*1000+b*100+c*10+d;y=d*1000+c*100+b*10+a;z=x*e;if()count++;}cout?"count="?count?endl;)答案:26072題:某數(shù)的17倍加上另一個數(shù)的19倍等于35587,兩數(shù)均在10000以內(nèi),且不為0,求滿足上述條件的解有多少個(不計重復(fù)的)?原程序:#include<iostream.h>#include<math.h>classmultiply(private:intn,count;public:voidnumber()(inti,j;count=0;for(i=l;i<10000;i++)for()if(i*17+j*l9==35587)cout?"number="?count?endl;);voidmain()multiplyob;ob.numberO;)答案:526073題:設(shè)某四位數(shù)的各位數(shù)字的平方和等于100,求滿足該條件的這些四位數(shù)中最大值。原程序:#include<iostream.h>#include<math.h>voidmain()(inti,j,k,h,x,;for(i=l;i<100;i++)for(j=l;j<100;j++)for(k=l;k<100;k++)for(h=1;h<100;h++)x=i*l000+j*1OO+k*l0+h;if(i*i+j*j+k*k+h*h==100)if()max=x;)cout?"Themaxis:"?max?endl;}答案:93316074題:有十進(jìn)制數(shù)字a,b,c,d,e,且a、b、c、d互不相等,求滿足算式abcd*e=dcba的所有abed數(shù)的和。原程序:#include<iostream.h>#include<math.h>voidmain()(inta,b,c,e,d,x,y,z,;fbr(a=0;a<=9;a++)for(b=0;b<=9;b++)for(c=0;c<=9;c++)for(d=0;d<=9;d++)for(e=0;e<=9;e++){x=a*1OOO+b*1OO+c*1O+d;y=d*lOOO+c*1OO+b*10+a;z=x*e;if()sum=sum+x;}cout?"sum="?sum?endl;}答案:32676075題:求出[1234,2346]內(nèi)恰好有兩位數(shù)字是6的所有整數(shù)的和。原程序:#include<iostream.h>classintegerintm,n,k,sum,count,x[4J;public:integer(intml,intnl,intkl){m=ml,n=nl;k=k1;}voidsolution()(inti,j,h,y;sum=0;for(i=m;i<=n;i++)(y=i;h=O;x[3]=y%10;y=(y-x[3])/10;x[2]=y%10;y=(y-x[2])/10;x[l]=y%l0;y=(y-x[l])/10;fbr(j=0;j<4;j++)if(x[j]==k)if(h==2)sum=sum+i;)}voiddisp_sum()cout?"Thesumis:"?sum?endl;};voidmain(){integerobj(1234,2346,6);obj.solution();obj.disp_sum();}答案:475836076題:求出[500,2000]內(nèi)所有既不能被5整除也不能被7的整數(shù)的個數(shù)。原程序:#include<iostream.h>#include<math.h>classaddition(longi,a,b,c,d,sum,count,abs_sub,max,min;public:addition(longa1Jongb1Jongcl,longdl){a=a1;b=b1;c=c1;d=d1;}voidsolution(){for(i=a;i<=b;i++)if(i%c!=0&&i%d!=0)count++;}voidadd_number()(cout?"Thenumberis:"?count?endl;));voidmain()(additionobj(500,2000,5,7);obj.add_number();)答案:10296077題:求出[500,2000]內(nèi)所有既不能被5整除也不能被7的整數(shù)中最大值與最小值差。原程序:#include<iostream.h>#include<math.h>classaddition(longi,a,b,c,d,max,min;pub
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《TPS豐田生產(chǎn)方式》課件
- 決定銷售業(yè)績的重要心態(tài)(課件)
- LNG氣化站應(yīng)急備用氣源自用建設(shè)項目可行性研究報告模板-立項備案
- 一年級語文上冊拼音aoe
- 2024年江蘇省招聘社區(qū)工作者題庫及參考答案
- 單位管理制度收錄大合集【人員管理篇】十篇
- 單位管理制度品讀選集【職員管理】十篇
- 樓梯 欄桿 欄板(一)22J403-1
- 果凍袋行業(yè)行業(yè)發(fā)展趨勢及投資戰(zhàn)略研究分析報告
- 中國返利網(wǎng)站行業(yè)市場調(diào)研分析及投資戰(zhàn)略咨詢報告
- 低溫雨雪冰凍災(zāi)害應(yīng)急救援準(zhǔn)備
- 幼兒園背景研究分析報告
- 圍墻維修 施工方案
- 創(chuàng)傷關(guān)節(jié)骨科年度總結(jié)
- 2022-2023學(xué)年江蘇省鹽城第一學(xué)期高一期末考試數(shù)學(xué)試卷及答案解析-普通用卷
- 醫(yī)師病理知識定期考核試題與答案
- 礦井提升容器課件
- 醫(yī)用冰箱溫度登記表
- 《潔凈工程項目定額》(征求意見稿)
- 城鎮(zhèn)燃?xì)庠O(shè)計規(guī)范
- 年零售藥店操作規(guī)程版
評論
0/150
提交評論