趣味程序

在这里插入图片描述
在这里插入图片描述

#include<iostream>
#include<string>
#include<cmath>
using namespace std;


class Fun
{
public:
	void Menu();
private:
	int chioce;
	void fun1();
	void fun2();
	void fun3();
	void fun4();
	void fun5();
};

void Fun::fun1()
{
	int i;
	float temp;
	system("cls");
	for(i=310000;i<320000;i++)
	{
		if(i/100%10==i/1000%10)
		{
			if(i%10 == i/10%10)
			{
				temp = i/1000%10;
				temp =temp*10 +(i/100%10);
				temp=temp*10 + (i/10%10);
				temp=temp*10+(i%10);
				if( temp == (int)sqrt(temp) * (int)sqrt(temp))
				{
					cout<<i<<endl;
				}
			}
		}
	}
	system("pause");
}

void Fun::fun2()
{
	int arr[6],i,j=0,k,temp;
	int temp1[6],temp2[6];
	int ans[6];
	system("cls");
	cout<<"输入6个四位数"<<endl;
	for(i=0;i<6;i++)
	{
		cin>>arr[i];
		temp1[i] = 10*(arr[i]/1000) + (arr[i]/10%10);
		temp2[i] = 10*(arr[i]%10) + (arr[i]/100%10);
	}
	for(i=0;i<6;i++)
	{
		if(temp1[i]>temp2[i])
			ans[j++] = arr[i];
	}
	for(i=0;i<j;i++)
	{
		for(k=i+1;k<j;k++)
		{
			temp=ans[i];
			ans[i]=ans[j];
			ans[j]=temp;
		}
	}

	for(i=0;i<j;i++)
	{
		cout<<ans[i]<<"\t";
	}
	cout<<endl;
	
	system("pause");
}

void Fun::fun3()
{
	system("cls");
	cout<<"   *"<<endl<<endl;
	cout<<"  ***"<<endl<<endl;
	cout<<" *****"<<endl<<endl;
	cout<<"*******"<<endl<<endl;
	cout<<" *****"<<endl<<endl;
	cout<<"  ***"<<endl<<endl;
	cout<<"   *"<<endl<<endl;
	system("pause");
}

void Fun::fun4()
{
	int arr[6][6];
	float score[6];
	int i,j,max,min,sum;;
	system("cls");
	for(i=0;i<6;i++)
	{
		cout<<"输入第"<<i+1<<"位选手成绩"<<endl;
		for(j=0;j<6;j++)
		{
			cout<<"第"<<j+1<<"位评委输入:";
			cin>>arr[i][j];
		}
	}

	for(i=0;i<6;i++)
	{
		sum=max=min=arr[i][0];
		
		for(j=1;j<6;j++)
		{
			sum += arr[i][j];
			if(arr[i][j]>max)
			{
				max=arr[i][j];
			}
			if(arr[i][j]<min)
			{
				min=arr[i][j];
			}
		}
		sum=sum-max-min;
		score[i]=sum/4.0;
	}

	for(i=0;i<6;i++)
	{
		cout<<"第"<<i+1<<"位选手成绩:"<<score[i]<<endl;
	}
	
	system("pause");
}
void Fun::fun5()
{
	system("cls");
	cout<<"123456  张三  男   2班    1998.05.05"<<endl;
	cout<<"654321  李四  男   1班    1998.05.06"<<endl;
	system("pause");
}

void Fun::Menu()
{
	do
	{
		system("cls");
		cout<<"    使用菜单选择趣味程序:"<<endl;	
		cout<<"============================"<<endl;	
		cout<<"1:侦破车牌号码"<<endl;
		cout<<"2:拆、组数排序"<<endl;
		cout<<"3:打印菱形图案"<<endl;
		cout<<"4:计算比赛选手得分"<<endl;
		cout<<"5:设计人资料"<<endl;
		cout<<"6:退出"<<endl;
		cout<<"============================"<<endl;	
		cin>>chioce;
		while(chioce<1||chioce>6)
		{
			cout<<"输入错误,重新输入:"<<endl;	
			cin>>chioce;
		}
		switch(chioce)
		{
		case 1:
			fun1();
			break;
		case 2:
			fun2();
			break;
		case 3:
			fun3();
			break;
		case 4:
			fun4();
			break;
		case 5:
			fun5();
			break;
		case 6:
			cout<<"感谢你的使用,再见!"<<endl;
			break;
		}
	}while(chioce!=6);
}

int main()
{
	Fun fun;
	fun.Menu();


	return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值