1)Write in a pyhton program with using database
1)Write in a pyhton
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int chart[10][5];
int workerarray[6];
int worker,worker1,worker2;
int selection,i;
srand (time (NULL));
do{
selection=monu();
switch(selection)
{
case 0:
printf("program terminated");
break;
case 1:
fill(chart,workerarray);
chartprint(chart);
break;
case 2:
printf("\nEnter Employees to Replace:");
scanf("%d%d",&worker1,&worker2);
change(chart,worker1,worker2);
break;
case 3:
printf("\nEmployee Who Will Be Asked for Weekly Work Details?");
scanf("%d",&worker);
daymonthwrite(chart,worker);
break;
default:
printf("\n incorrect entry \a\n");
}
}while(selection!=0);
return 0;
}
int menu()
{
int selection;
printf("\n_____MENU_____ \n");
printf("0- Close Program \n");
printf("1- Print Weekly Chart \n");
printf("2- Replace Employees \n");
printf("3- Get Employee Weekly Work Details \n");
printf("___________ \n");
printf("your choice : ");
scanf("%d",&selection);
return selection;
}
void fill(int array[][5],int array2[])
{
int i;
int n;
for(i=1;i<6;i++)
{
array2[i]=10;
}
printf("\n");
int value;
for(n=0;n<10;n++){
for(i=0;i<5;++i)
{
value=rand () % 5 + 1;
if(workercheck(array2,value)==-1){
i--;
continue;
}
else
array[n][i]=value;
}
}
}
int workercheck(int valuegenerated[],int value)
{
if(valuegenerated[value]!=0)
{
valuegenerated[value]--;
return 1;
}
else
return -1;
}
int chartprint(int dizi[][5])
{
printf("\t Monday Tuesday Wednesday Thursday Friday\n");
int n, i;
for(n=0;n<10;n++){
printf("%d. December:\t",n+1);
for(i=0;i<5;++i)
{
printf("%d\t",array[n][i]);
}
printf("\n");
}
}
void change(int array[][5],int c1,int c2)
{
int n,i;
int array2[10][5]={0};
for(n=0;n<10;n++){
for(i=0;i<5;++i)
{
if(array[n][i]==c2)
array2[n][i]=c2;
}
}
for(n=0;n<10;n++){
for(i=0;i<5;++i)
{
if(array[n][i]==c1)
{
array[n][i]=c2;
}
}
}
for(n=0;n<10;n++){
for(i=0;i<5;++i)
{
if(array[n][i]-array2[n][i]==0)
{
array[n][i]=c1;
}
}
}
printf("Process finished\n");
chartprint(array);
}
void daymonthwrite(int array[][5],int c)
{
int n,m;
for(n=0;n<10;n++)
for(m=0;m<5;m++)
if(array[n][m]==c)
{
printf("%d. December\t",n+1);
daycall(m);
printf("\n");
}
}
void daycall(int n)
{
switch(n)
{
case 0:
printf("Monday");
break;
case 1:
printf("Tuesday");
break;
case 2:
printf("Wednesday");
break;
case 3:
printf("Thursday");
break;
case 4:
printf("Friday");
break;
}
}
Step by step
Solved in 2 steps with 1 images