⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 谁是偷盗者解3.cpp

📁 谁是偷盗者问题的源码
💻 CPP
字号:
// 谁是偷盗者解3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	unsigned short comment[5];
	for(int i=1;i<=4;i++)
	{
		comment[i]=0;
		unsigned short a=0;
		unsigned short b=0;
		cout<<"请输入第"<<i<<"人陈述的2个人:";
		cin>>a>>b;
		if(a==0||b==0)
		{
			comment[i]=15;
		}
		else
		{
			unsigned short c=1;
			comment[i]=(1<<(a-1))|(1<<(b-1));
		}
	}
	unsigned short result=comment[1]&comment[2]&comment[3]&comment[4];
	switch(result)
	{
	case 1:
		cout<<1<<endl;
		break;
	case 2:
		cout<<2<<endl;
		break;
	case 4:
		cout<<3<<endl;
		break;
	case 8:
		cout<<4<<endl;
		break;
	default:
		cout<<"题目错误!"<<endl;
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -