⑴ C语言编程保安值班安排系统
#include<stdio.h>
#include<conio.h>
static char *WEEK[7] = {"Sun.", "Mon.", "Tues.", "Wedn.", "Thur.", "Fri.", "Sat."};
int IsChecked(const int pSon[]){
int i, j;
for (i=0; i<7; ++i){
for (j=0; j<7&&pSon[j]!=i; ++j);
if (j == 7) return 0;
}
return 1;
}
void main()
{
int t=0, j, person[7];
long i;
printf("ZHAO, QIAN, SUN, LI, ZHOU, WU, CHEN\n\n");
for (i=0; i<2097152; ++i){
for (j=0; j<7; ++j){
person[j] = (i>>(3*j)) & 7L;
}
if (!(person[0]==2 || person[0]==4))continue;
else if (!(person[1]==1 || person[1]==6))continue;
else if (!(person[2]==3 || person[2]==0))continue;
else if (!(person[3]==5))continue;
else if (!(person[4]==1 || person[4]==4 || person[4]==6))continue;
else if (!(person[5]==2 || person[5]==5))continue;
else if (!(person[6]==3 || person[6]==6 || person[6]==0))continue;
else if (!IsChecked(person)) continue;
for (j=0; j<7; ++j){
printf("%s ", WEEK[person[j]]);
}
printf("\n");
++t;
}
printf("\n%d Methods!\n", t);
getch();
}
结果:
赵、 钱、 孙、 李、 周、 吴、 陈
四 六 三 五 一 二 日
四 一 三 五 六 二 日
四 六 日 五 一 二 三
四 一 日 五 六 二 三
⑵ 保安轮休安排(C语言)
要三重循环,在循环内层判断1-7是否排满且无重复。你仔细想想吧,不会很难,只是我很懒 懒得想
⑶ 帮忙搞C语言课程设计,(上课没学好,拜托)保安值班管理系统
//.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "string.h"
#include<stdio.h>
char *WEEK[7] = {"星期天", "星期一", "星期二", "星期三","星期四","星期五","星期六"};
struct demand
{
char name[5];
int day[7];
} man[7];
main()
{
int IsChecked(int p[]);
int t=0, j, ren[7];
long i,k;
printf("****************保安值班系统****************\n");
printf("请各位分别输入各自合适的休假日,如赵保安选择星期二和星期三,就输入2 3 8 8 8 8 8.\n");
printf(" 数字0 1 2 3 4 5 6分别代表星期天 星期一 星期二 星期三 星期四 星期五 星期六,注意要输入星期天请输入数字0 \n");
for(i=0;i<7;i++)
{
printf("请第%d个人输入\n",i+1);
for(k=0;k<7;k++)
{
scanf("%d",&man[i].day[k]);
}
printf("你输入的day是:");
for(k=0;k<7;k++)
{
printf("%d ",man[i].day[k]);
}
printf("\n");
}
printf("**********************************************");
printf("\n* 赵, 钱, 孙, 李, 周 , 吴, 陈 , *\n");
printf("*--------------------------------------------*\n");
printf("");
for (i=0; i<2097152; ++i)
{
for (j=0; j<7; ++j)
{
ren[j]= (i>>(3*j))&7; //*通过这个循环,穷尽0-7在数组中所有的排列组合方式*//
}
if (!(ren[0]==man[0].day[0] || ren[0]==man[0].day[1]||ren[0]==man[0].day[2]||ren[0]==man[0].day[3]||ren[0]==man[0].day[4]||ren[0]==man[0].day[5]||ren[0]==man[0].day[6]))continue;//*如果赵保安不是休周二或周四,就不用循环了。*//
else if (!(ren[1]==man[1].day[0] || ren[1]==man[1].day[1]||ren[1]==man[1].day[2]||ren[1]==man[1].day[3]||ren[1]==man[1].day[4]||ren[1]==man[1].day[5]||ren[1]==man[1].day[6]))continue; //*如果钱保安不是休周一或周六,就不用循环了。*//
else if (!(ren[2]==man[2].day[0] || ren[2]==man[2].day[1]||ren[2]==man[2].day[2]||ren[2]==man[2].day[3]||ren[2]==man[2].day[4]||ren[2]==man[2].day[5]||ren[2]==man[2].day[6]))continue; //*如果孙保安不是休周三或周日,就不用循环了。*//
else if (!(ren[3]==man[3].day[0] || ren[3]==man[3].day[1]||ren[3]==man[3].day[2]||ren[3]==man[3].day[3]||ren[3]==man[3].day[4]||ren[3]==man[3].day[5]||ren[3]==man[3].day[6]))continue; //*如果李保安不是休周五,就不用循环了。*//
else if (!(ren[4]==man[4].day[0] || ren[4]==man[4].day[1]||ren[4]==man[4].day[2]||ren[4]==man[4].day[3]||ren[4]==man[4].day[4]||ren[4]==man[4].day[5]||ren[4]==man[4].day[6]))continue; //*如果周保安不是休周一或周四或周六,就不用循环了。*//
else if (!(ren[5]==man[5].
⑷ 求一个c语言保安值班安排系统编程,我大一不太会做。。。。。
#include"stdafx.h"
#include<iostream>
usingnamespacestd;
staticchar*day[]=
{
"星期一","星期二","星期三","星期四","星期五","星期六","星期日"
};
int_tmain(intargc,_TCHAR*argv[])
{
inta,b,c,d,e,f,g,s;
d=4;
f=1;
s=0;
for(a=0;a<7;a++)
{
if((a!=1&&a!=3)||a==d||a==f)
continue;
for(b=0;b<7;b++)
{
if((b!=0&&b!=5)||b==a||b==d||b==f)
continue;
for(c=0;c<7;c++)
{
if((c!=2&&c!=6)||c==b||c==a||c==d||c==f)
continue;
for(e=0;e<7;e++)
{
if((e!=0&&e!=3&&e!=5)||e==d||e==c||e==b||e==a||e==f)
continue;
for(g=0;g<7;g++)
{
if((g!=2&&g!=5&&g!=6)||g==f||g==e||g==d||g==c||g==b||g==a)
continue;
++s;
cout<<"Solution:"<<s<<endl;
cout<<"赵 钱 孙 李 周 吴 陈"<<endl;
cout<<"=============================================================="<<endl;
cout<<day[a]<<" "<<day[b]<<" "<<day[c]<<" "<<day[d]<<" "
<<day[e]<<" "<<day[f]<<" "<<day[g]<<endl<<endl;
}
}
}
}
}
}
⑸ 11、保安值班安排系统用C编程
#include<stdio.h> #include<conio.h> static char *WEEK[7] = {"Sun.", "Mon.", "Tues.", "Wedn.", "Thur.", "Fri.", "Sat."}; int IsChecked(const int pSon[]){ int i, j; for (i=0; i<7; ++i){ for (j=0; j<7&&pSon[j]!=i; ++j); if (j == 7) return 0; } return 1; } void main() { int t=0, j, person[7]; long i; printf("ZHAO, QIAN, SUN, LI, ZHOU, WU, CHEN\n\n"); for (i=0; i<2097152; ++i){ for (j=0; j<7; ++j){ person[j] = (i>>(3*j)) & 7L; } if (!(person[0]==2 || person[0]==4))continue; else if (!(person[1]==1 || person[1]==6))continue; else if (!(person[2]==3 || person[2]==0))continue; else if (!(person[3]==5))continue; else if (!(person[4]==1 || person[4]==4 || person[4]==6))continue; else if (!(person[5]==2 || person[5]==5))continue; else if (!(person[6]==3 || person[6]==6 || person[6]==0))continue; else if (!IsChecked(person)) continue; for (j=0; j<7; ++j){ printf("%s ", WEEK[person[j]]); } printf("\n"); ++t; } printf("\n%d Methods!\n", t); getch(); } 结果: 赵、 钱、 孙、 李、 周、 吴、 陈 四六三五一二日 四一三五六二日 四六日五一二三 四一日五六二三
⑹ 请问c语言vc6.0保安轮休问题应该怎么编程
方法/步骤
首先我们先去网上找到这个软件的安装包,然后安装到自己电脑上,在安装的过程中,W7系统可能会说软件与系统不兼容,这个没事的,继续安装就是
安装好后双击这个软件在桌面上的图标,打开软件后,我们需要建立c语言编写文件,点击文件新建一个C++source file,然后开始编写程序!
编写程序的过程中,要理清思路,先把头文件写上,该注释的地方还是要注释,这样以后看程序的时候不至于不懂!
把程序写好后,一定要保存,其实我们在写程序的时候就应该写一句保存一次,这是因为这个软件有时候运行不稳定!万一出现程序闪退,我们写的程序就没有了,这让人很抓狂的!
保存好程序后,我们可以开始编译执行链接程序了,如果一切无误的话,会生成一个exe文件,我们就可以实现编写的功能了,如果程序报错,那么我们需要找到错误的地方进行改正!
说了这么多,是时候自己动手验证了,这个软件使用起来很方便,功能也很强大,多练习几次就一定会使用的!
⑺ C语言求教
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const int N = 8;
int count = 0;
void fun(char restTable[N+1],int info[N][2],int num){
if(num == N-1){
count++;
printf("\nsolution %d:\n",count);
for(int i=1;i<N;++i){
printf("星期%d休息:%c.\n",i,restTable[i]);
}
return;
}
if(restTable[info[num][0]] < 'A'){
restTable[info[num][0]] = 'A'+num;
fun(restTable,info,num+1);
restTable[info[num][0]] = ' ';
}
if(restTable[info[num][1]] < 'A'){
restTable[info[num][1]] = 'A'+num;
fun(restTable,info,num+1);
restTable[info[num][1]] = ' ';
}
return;
}
int main()
{
int cases = 0;
printf("input test cases:");
scanf("%d",&cases);
while(cases--){
char restTable[N+1]={' '};
memset(restTable,' ',sizeof(restTable));
int info[N][2];
printf("cases:%d\n",cases);
for(int i=0;i<N-1;++i){
printf("%c请输入两天自己想要休假的日期(星期):",'A'+i);
scanf("%d",&info[i][0]);
scanf("%d",&info[i][1]);
}
count = 0;
fun(restTable,info,0);
}
return 0;
}
⑻ C语言实现排班系统。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
structPerson
{
intcnDay;
intday[7];//开的足够大,假设某个人可能7天都忙--.
charpName[10];
};
charname[7][10];//7个人,每人名字不超过10
Personp[7];//7个人的信息
boolisEmpty[7]={false};//标记7天已占用情况
voidsetTable(inti)
{
if(i==7)
{
printf("星期一星期二星期三星期四星期五星期六星期日 ");
for(intk=0;k<7;++k)
{
printf("%s",name[k]);
}
printf(" ");
return;
}
intk=0;
for(;k<p[i].cnDay;++k)
{
if(isEmpty[p[i].day[k]]==false)
{
isEmpty[p[i].day[k]]=true;
strcpy(name[p[i].day[k]],p[i].pName);
setTable(i+1);
isEmpty[p[i].day[k]]=false;
}
}
}
intmain()
{
intday;
intcount;
for(inti=0;i<7;++i)
{
printf("输入第%d个人的名字,然后依次输入每个人的繁忙日,输入0结束此人信息录入! ",i+1);
count=0;
scanf("%s",p[i].pName);
scanf("%d",&day);
while(day!=0)
{
p[i].day[count]=day-1;
++count;
scanf("%d",&day);
}
p[i].cnDay=count;
}
setTable(0);
return0;
}
⑼ c语言程序课程设计保安值班安排系统怎么做
某公司有7名保安人员:赵、钱、孙、李、周、吴、陈。由于工作需要进行轮休制度,一星期中每人休息一天。预先让每一个人选择自己认为合适的休息日。请编制一程序,打印轮休的所有可能方案。当然使每个人都满意,例如每人选择的休息日如下:
赵:星期二、星期四
钱:星期一、星期六
孙:星期三、星期日
李:星期五
周:星期一、星期四、星期六
吴:星期二、星期五
陈:星期三、星期六、星期日
解法一:#include "stdafx.h"
#include <iostream>
using namespace std;
static char * day[] =
{
"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"
};
int _tmain(int argc, _TCHAR* argv[])
{
int a, b, c, d, e, f, g, s;
d = 4;
f = 1;
s = 0;
for( a = 0; a < 7; a++ )
{
if( (a !=1 && a != 3) || a == d || a == f )
continue;
for( b = 0; b < 7; b++ )
{
if( (b != 0 && b != 5) || b == a || b == d || b == f )
continue;
for( c = 0; c < 7; c++ )
{
if( (c != 2 && c != 6) || c == b || c == a || c == d || c == f )
continue;
for( e = 0; e < 7; e++ )
{
if( (e != 0 && e != 3 && e != 5) || e == d || e == c || e == b || e == a || e == f)
continue;
for( g = 0; g < 7; g++ )
{
if( (g != 2 && g != 5 && g != 6) || g == f || g == e || g == d || g == c || g == b || g == a )
continue;
++s;
cout << "Solution: " << s << endl;
cout << "赵\t钱\t孙\t李\t周\t吴\t陈" << endl;
cout << "==============================================================" << endl;
cout << day[a] << "\t" << day[b] << "\t" << day[c] << "\t" << day[d] << "\t"
<< day[e] << "\t" << day[f] << "\t" << day[g] << endl << endl;
}
}
}
}
}
}
运行结果:
Solution: 1
赵 钱 孙 李 周 吴 陈
==============================================================
星期四 星期一 星期三 星期五 星期六 星期二 星期日
Solution: 2
赵 钱 孙 李 周 吴 陈
==============================================================
星期四 星期一 星期日 星期五 星期六 星期二 星期三
Solution: 3
赵 钱 孙 李 周 吴 陈
==============================================================
星期四 星期六 星期三 星期五 星期一 星期二 星期日
Solution: 4
赵 钱 孙 李 周 吴 陈
==============================================================
星期四 星期六 星期日 星期五 星期一 星期二 星期三
解法二:#include<stdio.h>
char *WEEK[7] = {" 7.", " 1.", " 2.", " 3.", " 4.", " 5.", " 6."};
int IsChecked(int p[])
{
int i, j;
for (i=0; i<7; ++i)
{
for (j=0; j<7&&p[j]!=i; ++j); //*从0到6循环,如果数组中缺少0-6的任何一位数字,则返回0,如果0-6亿权,则返回。*//
if (j == 7) return 0;
}
return 1; //*这个函数的作用是确保0-6这7个数字均包含在该书组中*//
}
main()
{
int t=0, j, ren[7];
long i;
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("**********************************************");
printf("\n*zhao, qian, sun, li, zhou, wu, chen *\n");
printf("*--------------------------------------------*\n");
printf("");
for (i=0; i<2097152; ++i)
{
for (j=0; j<7; ++j)
{
ren[j]= (i>>(3*j))&7; //*通过这个循环,穷尽0-7在数组中所有的排列组合方式*//
}
if (!(ren[0]==2 || ren[0]==4))continue; //*如果赵保安不是休周二或周四,就不用循环了。*//
else if (!(ren[1]==1 || ren[1]==6))continue;//*如果钱保安不是休周一或周六,就不用循环了。*//
else if (!(ren[2]==3 || ren[2]==0))continue;//*如果孙保安不是休周三或周日,就不用循环了。*//
else if (!(ren[3]==5))continue; //*如果李保安不是休周五,就不用循环了。*//
else if (!(ren[4]==1 || ren[4]==4 || ren[4]==6))continue; //*如果周保安不是休周一或周四或周六,就不用循环了。*//
else if (!(ren[5]==2 || ren[5]==5))continue; //*如果吴保安不是休周二或周五,就不用循环了。*//
else if (!(ren[6]==3 || ren[6]==6 || ren[6]==0))continue;//*如果陈保安不是休周三或周六或周日,就不用循环了。*//
else if (!IsChecked(ren)) continue; //*至此,所有的保安可按他们的愿望休假,但是此时的方案可能有两个人同休一天的*//
//*情况发生,因此用这个函数排除,如果0-6这七个数字(一周七天)任何一个包含在数组中则此次匹配失败。*//
for (j=0; j<7; ++j){
printf(" %s ", WEEK[ren[j]]);
}printf(" *");
printf("\n"); //*输出成功匹配方案*//
++t; //*记录成功匹配个数*//
}
printf("*--------------------------------------------*");
printf("\n* %d zhong qing kuang! *", t); //*输出成功匹配方案个数*//
printf("\n**********************************************");
getch();
}
结果是
**********************************************
*zhao, qian, sun, li, zhou, wu, chen *
*--------------------------------------------*
4. 6. 3. 5. 1. 2. 7. *
4. 1. 3. 5. 6. 2. 7. *
4. 6. 7. 5. 1. 2. 3. *
4. 1. 7. 5. 6. 2. 3. *
*--------------------------------------------*
* 4 zhong qing kuang! *