c++第四次作业

1.输出99乘法表
#include <iostream>
using namespace std;
int main()
{
	int i,j,k;
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=i;j++)
			cout<<i<<"*"<<j<<"="<<i*j<<" ";
		cout<<endl;
	}
		return 0;
}
 

2.百鸡百钱问题

#include <iostream>
using namespace std;
int main()
{
	int x,y,z,count=0;
	cout<<"可能的情况有:"<<endl;
		for(x=0;x<=20;x++)
			for(y=0;y<=33;y++)
				for(z=0;z<=300;z++)
		if(5*x+3*y+z/3==100&&x+y+z==100)
	{
        ++count;
		cout<<count<<"鸡母数:"<<x<<"只,鸡翁数:"<<y<<"只,鸡雏数:"<<z<<"只"<<endl;
	}
		return 0;
}
3.输出星号图
#include<iostream.h>
void main()
{
	int m,n,k;
	for(m=0;m<=5;m++)
	{
		for(n=0;n<=5-m;n++)
		 cout<<" ";
		 cout<<"*";
		 if(m==0) cout<<endl;
		 else if(m>=1&&m<=4)
		 {
			 for(k=1;k<=2*m-1;k++)
				 cout<<" ";
			 cout<<"*"<<endl;
		 }
		 else
		 {
			 for(k=1;k<=10;k++)
				 cout<<"*";cout<<endl;
		 }
	}

}


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值