C++作业4—星号图/双色球/乘法口诀表

1、星号图

#include<iostream.h>
void main()
{
	int a,b,c;
	for(a=1;a<=6;a++)
		cout<<" ";
	cout<<"*"<<endl;
	for(b=1;b<=5;b++)
	{
		for(c=1;c<=6-b;c++)
			cout<<" ";
		cout<<"*";
			for(a=1;a<=2*b-1;a++)
				cout<<" ";
			cout<<"*";
			cout<<endl;
	}
	for(a=1;a<=13;a++)
		cout<<"*";
}


2、双色球

#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	for(a=0;a<=3;a++)
		for(b=0;b<=3;b++)
		{
			c=8-b-a;
			if(c<=6)cout<<"红球:"<<a<<",白球:"<<b<<",黑球:"<<c<<endl;
		}
}


3、乘法口诀表

#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	for(a=1;a<10;a++)
	{
		for(b=1;b<=a;b++)
		{
			c=a*b;
			cout<<b<<"x"<<a<<"="<<c<<" ";
		}
		cout<<endl;
	}
	return 0;
}


你可能感兴趣的:(C++作业4—星号图/双色球/乘法口诀表)