资源描述:
《云南大学 软件学院 c语言实验 米粒问题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、/*米粒问题*/#includeintmain(){inta=1,i,sum=0;printf("Inputanumber:%d",i);scanf("%d",&i);if(i<=64){sum=sum+a;a=a*2;}printf("Thetotalmnubeis:%d",sum);return0;}/*乘法口诀表*/#include
longa=10000,b,c=2800,d,e,f[2801],g;intmain()
{for(;b-c;)
f[b++]=a/5;
for(;d=0,g=c*2;c-=14,printf("%.
2、4d",e+d/a),e=d%a)
for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);return0;
}
/*利润问题*/#includeintmain(){intelery,extra;floata;printf("pleaseinputtheelery:");scanf("%d",&elery);a=(elery-1)/100000;switch(a){case0:extra=elery*10/100;printf("Theextrais%f",extra);}return0;}/*奖学金问题*/#include
3、 int main(){int a;float profit,income;printf("Please input the profit:");scanf("%f",&profit);a=(profit-1)/100000;switch(a){case 0:income=profit/10;break;case 1:income=(profit-100000)*0.075+10000;break;case 2:case 3:income=(profit-200000)*0.05+10000+7500;break;case 4:case 5:income=(p
4、rofit-400000)*0.03+10000+7500+10000;break;case 6:case 7:case 8:case 9:income=(profit-600000)*0.01+10000+7500+10000+6000;break;case 10:income=(profit-1000000)*0.01+10000+7500+10000+6000+6000;} printf("奖金数值为:%f",income); return 0;}/*星星问题*/(暂时还有问题)#includeintmain(){intx,y,z;pri
5、ntf("Inputanumber:”);scanf("%d",&z);for(x=1;x<=z;x++){for(y=1;y<=z;y++){if((z-1)/2+x-y>=0&&x-y-(z-1)/2<=0&&x+y-(z-1)/2>=0&&x+y-(3*z-1)/2<=0)printf("*");elseprintf("");}printf("");}return0;}if((z-1)/2+x-y>=0&&x-y-(z-1)/2<=0&&x+y-(z+3)/2>=0&&x+y-(3*z+1)/2<=0)修改为下面换算问题#includeintmain
6、(){inta,b,c,day;printf("Pleaseinputthreenumbers:");scanf("%d%d%d",&a,&b,&c);b<=12;c<=31;day=365*a+30*b+c;printf("天数为:%d",day);return0;}#includeintmain(){inta,b,c,day;printf("Inputthreenumbers:");scanf("%d%d%d",&a,&b,&c);if(a%4==0
7、
8、a%100!=0
9、
10、a%400==0){if(c<=31)switch(b){case1:day=c;b
11、reak;case3:day=60+c;break;case5:day=121+c;break;case7:day=182+c;break;case8:day=213+c;break;case10:day=274+c;break;case12:day=335+c;break;}switch(b){if(c<=30)case4:day=91+c;break;case6:day=152+c;break;case9:day=244+c;break;case11:day=305+c;break;}s