SCL-90検出システムカリキュラム設計

17658 ワード

数年前に作ったカリキュラムのデザインは、今日パソコンで発見され、参考にしなければならない学生に共有されています.ファイルはC言語で作成され、ソースコードの接尾辞名は.c,visual studioでコンパイルしないでください.
   
/*
Curriculum Design Programme    SCL-90
  
1.               2.              3.           
4.       '1~5' 5.                6.     
7.            
     
1.       
2.      
    

     system("cls");
       fflush(stdin);
*/
#include "stdio.h"
#include "conio.h"
#include "string.h"
#include "malloc.h"
#include "time.h"
typedef struct UserScore
{
	int QES[90];
	int SumScore;
	int Female_Num;
	int Male_Num;
	double Somatization;//   1,4,12,27,40,42,48,49,52,53,56,58
	double Obsessive_Compulsive;//3,9,10,28,38,45,46,51,55,65
	double Interpersonal_Sensitivity;//6,21,34,36,37,41,61,69,73
	double Depression;//5,14,15,20,22,26,29,30,3l,32,54,7l,79
	double Anxiety;//2,17,23,33,39,57,72,78,80,86
	double Hostility;//11,24,63,67,74,8l
	double Photic_Anxiety;//13,25,47,50,70,75,82
	double Paranoididefition;//8,18,43,68,76,83
	double Psychotieism;//7,16,35,62,77,84,85,87,88,90
	double Others;//19,44,59,60,64,66,89
	double Male_Average;//(  -     )/     
	char Severity_YN;
}UserScore;
typedef struct TestUser
{
	char name[40];
	char sex;
	int age;
	UserScore *score;
	struct TestUser *next;
}TestUser;

char *Question[90]={
"  ",
"    ,     ",
"               ",
"     ",
"        ",
"       ",
"           ",
"        ",
"   ",
"               ",
"       ",
"  ",
"          ",
"         ,    ",
"        ",
"          ",
"  ",
"           ",
"    ",
"    ",
"             ",
"    ,           ",
"           ",
"           ",
"     ",
"      ",
"  ",
"        ",
"    ",
"    ",
"    ",
"       ",
"    ",
"          ",
"           ",
"        、    ",
"         ,    ",
"               ",
"      ",
"        ",
"       ",
"    ",
"        、   ",
"    ",
"        ",
"      ",
"    、    、     ",
"     ",
"        ",
"             、     ",
"     ",
"       ",
"      ",
"        ",
"       ",
"             ",
"         ",
"       ",
"      ",
"    ",
"                ",
"            ",
"            ",
"    ",
"      、  ",
"      ",
"            ",
"          ",
"         ",
"                  ",
"          ",
"        ",
"             ",
"      ",
"          ",
"                ",
"             ",
"          ",
"          ",
"                 ",
"      ",
"          ",
"          ",
"             ",
"                 ",
"          ",
"            ",
"           ",
"      ",
"          "
};
//Questions
int InterfacialOutput();//      
int MainIndex(char e,TestUser *ListHead);//     
int TestUserCreate();//         
int QuestionAnswer(UserScore *sco);//      
char TestUserLogin();//               
int AUserLogin();
int TestedUserLogin();//         
int NumTestResultOutput(TestUser *,int);//            
int TestUserListOutput(TestUser *);//       
int FirstFileRead(TestUser *);//   
int FinishFileWrite(TestUser *);//   
int TestResultOutput(TestUser *);//      
int QESOutPut(TestUser *);//        
int GResultOutput(TestUser *);
int AResultOutput(TestUser *);
int DataDelete(TestUser*,int);//        

int InterfacialOutput(TestUser *ListHead)
{
	fflush(stdin);
	system("cls");
	printf("------------------------------------------
"); printf(" SCL-90


"); printf(" ‘1’
"); printf("-- ‘2’
"); printf("---- ‘e’

"); printf("------------------------------------------
"); printf(" 15
"); printf("------------------------------------------
"); char Index; int re; Index=getch();//Index , Index re=MainIndex(Index,ListHead); while(!re)// re 0 , Index , { Index=getch(); re=MainIndex(Index,ListHead); } if(re==1)return 0;// re 1 , , 。 if(re==2)return 1;// re 2 , 。 } int MainIndex(char e,TestUser *ListHead) { char logselect;// int select;// switch(e) { case '1': { logselect=TestUserLogin();// switch(logselect)// { case 's':// { select=TestedUserLogin(ListHead);// , 0 if(select)NumTestResultOutput(ListHead,select); else return 1; } case 'o':return 1;// case 'n':// { TestUserCreate(ListHead); QuestionAnswer(ListHead->next->score); while(!GResultOutput(ListHead->next)) // GResultOutput(ListHead->next); return 1; } } break; } case '2':// { if(AUserLogin()) select=TestUserListOutput(ListHead);// // select , , else return 1; if(select) while(select&&(!NumTestResultOutput(ListHead,select))) select=TestUserListOutput(ListHead); return 1; break; } case 'e':return 2;break;// , 2 default :// printf(" ,
"); return 0; } return 1; } int QuestionAnswer(UserScore *sco) { system("cls"); sco->SumScore=0; sco->Female_Num=0; sco->Male_Num=0; sco->Severity_YN=0; int i; for (i = 0; i < 90; ++i) { fflush(stdin); system("cls"); printf(" %d:%s
",i+1,Question[i]); printf(" :1- 2- 3- 4- 5-
"); int grade; while(fflush(stdin), scanf("%d", &grade) != 1) printf(" , 1~5!
"); while(!(grade>=1&&grade<=5)) { printf(" , 1~5
"); while(fflush(stdin), scanf("%d", &grade) != 1) printf(" , 1~5!
"); } sco->QES[i]=grade; sco->SumScore+=grade; if(grade==1)// sco->Female_Num++; else if(grade==2)// sco->Male_Num++; else // , y yes { sco->Male_Num++; sco->Severity_YN='y'; } } sco->Somatization=(double)( sco->QES[1-1]+sco->QES[4-1]+sco->QES[12-1]+ sco->QES[27-1]+sco->QES[40-1]+sco->QES[42-1]+ sco->QES[48-1]+sco->QES[49-1]+sco->QES[52-1]+ sco->QES[53-1]+sco->QES[56-1]+sco->QES[58-1])/12; sco->Obsessive_Compulsive=(double)( sco->QES[3-1]+sco->QES[9-1]+sco->QES[10-1]+ sco->QES[28-1]+sco->QES[38-1]+sco->QES[45-1]+ sco->QES[46-1]+sco->QES[51-1]+sco->QES[55-1]+sco->QES[65-1])/10; sco->Interpersonal_Sensitivity=(double)(sco->QES[6-1]+sco->QES[21-1]+sco->QES[34-1]+ sco->QES[36-1]+sco->QES[37-1]+sco->QES[41-1]+ sco->QES[61-1]+sco->QES[69-1]+sco->QES[73-1])/9; sco->Depression=(double)( sco->QES[5-1]+sco->QES[14-1]+sco->QES[15-1]+ sco->QES[20-1]+sco->QES[22-1]+sco->QES[26-1]+ sco->QES[29-1]+sco->QES[30-1]+sco->QES[3l-1]+ sco->QES[32-1]+sco->QES[54-1]+sco->QES[7l-1]+sco->QES[79-1])/13; sco->Anxiety=(double)( sco->QES[2-1]+sco->QES[17-1]+sco->QES[23-1]+ sco->QES[33-1]+sco->QES[39-1]+sco->QES[57-1]+ sco->QES[72-1]+sco->QES[78-1]+sco->QES[80-1]+sco->QES[86-1])/10; sco->Hostility=(double)( sco->QES[11-1]+sco->QES[24-1]+sco->QES[63-1]+ sco->QES[67-1]+sco->QES[74-1]+sco->QES[8l-1])/6; sco->Photic_Anxiety=(double)( sco->QES[13-1]+sco->QES[25-1]+sco->QES[47-1]+ sco->QES[50-1]+sco->QES[70-1]+sco->QES[75-1]+sco->QES[82-1])/7; sco->Paranoididefition=(double)(sco->QES[8-1]+sco->QES[18-1]+sco->QES[43-1]+ sco->QES[68-1]+sco->QES[76-1]+sco->QES[83-1])/6; sco->Psychotieism=(double)( sco->QES[7-1]+sco->QES[16-1]+sco->QES[35-1]+ sco->QES[62-1]+sco->QES[77-1]+sco->QES[84-1]+ sco->QES[85-1]+sco->QES[87-1]+sco->QES[88-1]+sco->QES[90-1])/10; sco->Others=(double)( sco->QES[19-1]+sco->QES[44-1]+sco->QES[59-1]+ sco->QES[60-1]+sco->QES[64-1]+sco->QES[66-1]+sco->QES[89-1])/7; sco->Male_Average=(double)(sco->SumScore-sco->Female_Num)/sco->Male_Num;// if(sco->Severity_YN=='n')// { if(sco->SumScore>160)sco->Severity_YN='y'; else if(sco->Male_Num>43)sco->Severity_YN='y'; } } int TestResultOutput(TestUser *tester) { fflush(stdin); system("cls"); printf("------------------------------------------------
"); printf("
"); printf(" :%s
",tester->name); printf(" :%c
",tester->sex); printf(" :%d

",tester->age); printf("-------- ------------------------------------
"); printf("---- :%-8d
",tester->score->SumScore); printf(" :%-8d
",tester->score->Female_Num); printf(" :%-8d
",tester->score->Male_Num); printf(" :%1.2f
",tester->score->Male_Average); if(tester->score->Severity_YN=='y')// printf(" ,


"); printf("-------- ----------------------
"); printf(" (Somatization): %5.2f
",tester->score->Somatization); printf(" (Obsessive Compulsive: %5.2f
",tester->score->Obsessive_Compulsive); printf(" (interpersonal sensitivity):%5.2f
",tester->score->Interpersonal_Sensitivity); printf(" (depression): %5.2f
",tester->score->Depression); printf(" (anxiety): %5.2f
",tester->score->Anxiety); printf(" (hostility): %5.2f
",tester->score->Hostility); printf(" (Photic anxiety): %5.2f
",tester->score->Photic_Anxiety); printf(" (Paranoididefition): %5.2f
",tester->score->Paranoididefition); printf(" (psychotieism): %5.2f
",tester->score->Psychotieism); printf(" (additionalitems): %5.2f
",tester->score->Others); printf("----------------------------------------
"); return 1; } int GResultOutput(TestUser *tester)// { if(TestResultOutput(tester)) { printf(" ‘e’ , ‘s’
"); char out=getch(); while(out!='e'&&out!='s') out=getch(); if(out=='s') { QESOutPut(tester); return 0; } return 1; } } int QESOutPut(TestUser *tester)// { system("cls"); int i; for ( i = 0; i < 90; ++i) { printf(" %d:%s
",i+1,Question[i]); printf(" :%d
",tester->score->QES[i]); } printf(" ‘e’
"); char out=getch(); while(out!='e') out=getch(); return 1; } char TestUserLogin()// , { printf("------------- --------
"); printf(" ‘1’
"); printf("-- ‘2’
"); printf("---------- ‘e’
"); char select; select=getch(); while(!(select=='1'||select=='2'||select=='e')) { printf(" ,
"); select=getch(); } if(select=='1') select='n'; else if (select=='2') select='s'; else if(select=='e') select='o'; return select; } int TestUserCreate(TestUser * ListHead) { TestUser *new=(TestUser *)malloc(sizeof(TestUser)); new->score=(UserScore *)malloc(sizeof(UserScore)); printf("------- -------


"); printf(" :"); gets(new->name); printf(" , ‘m’ ‘f’
"); new->sex=getch(); while(!(new->sex=='f'||new->sex=='m')) { printf(" ,
"); new->sex=getch(); } printf("%c
",new->sex); printf(" :"); while(fflush(stdin), scanf("%d", &new->age)!= 1) printf(" , !
"); while(new->age>100||new->age<1) { printf(" ,
"); while(fflush(stdin), scanf("%d", &new->age) != 1) printf(" , !
"); } new->next=ListHead->next; ListHead->next=new; printf(" ,
"); getch(); return 1; }// int TestedUserLogin(TestUser *ListHead)// { system("cls"); printf("-------------------------------------
"); if(ListHead->next) { char name[50]; int num=0,i=1; printf(" :"); gets(name); fflush(stdin); TestUser *p=ListHead->next; for(;p;p=p->next,i++) if(!strcmp(name,p->name))num=i;// if(!num) { printf(" , ,
"); getch(); } return num;// } else { printf(" !
"); getch(); return 0;// } } int AUserLogin() { system("cls"); printf("-----------------------------
"); printf(" :
"); int code; scanf("%d",&code); if (code!=94698) { printf(" !
"); getch(); return 0; } else return 1; } int TestUserListOutput(TestUser *ListHead)// { system("cls"); TestUser *p; int i=1,select; if(ListHead->next) { for(p=ListHead->next,i=1;p;p=p->next,i++) { printf("%d.%s :%d",i,p->name,p->age); (p->sex=='m')?printf(" :
"):printf(" :
"); } i--; printf("--------------------------------------------
"); printf(" 1~%d
, ‘0’
",i); for (;;) // { fflush(stdin); if((scanf("%d",&select)!=1)||(!(select>=0&&select<=i))) { printf(" , 1~%d
",i); continue; } else break; fflush(stdin); return select; } } else { printf(" !
"); getch(); return 0; } } int NumTestResultOutput(TestUser *ListHead,int num) { TestUser *p=ListHead; int i,select; for(i=0;i!=num;i++)p=p->next; select=AResultOutput(p);// while(!select)select=AResultOutput(p);// if(select==2) { DataDelete(ListHead,num);// 2 return 0; } return 1; } int AResultOutput(TestUser *tester) { if(TestResultOutput(tester)) { printf(" ‘e’ , ‘s’ , ‘d’
"); char select=getch(); while(select!='e'&&select!='s'&&select!='d') select=getch(); if(select=='s') { QESOutPut(tester); return 0; } if(select=='d')return 2; return 1; } } int DataDelete(TestUser* ListHead,int num) { TestUser *p=ListHead,*q; int i; for(i=0;i!=num-1;i++)p=p->next; q=p->next; p->next=q->next; free(q->score); free(q); printf(" ,
"); getch(); return 1; } int FirstFileRead(TestUser *ListHead) { printf("-----------------------------------
"); printf("

"); FILE *data=fopen("data","rb"); if(data==NULL) { data=fopen("data","wb"); if(!fclose(data)) printf(" ,
"); } else { printf(" !
"); int result=0; do { TestUser *p=(TestUser *)malloc(sizeof(TestUser)); result=fread(p,sizeof(TestUser),1,data); if(result==1) { p->score=(UserScore *)malloc(sizeof(UserScore)); if(fread(p->score,sizeof(UserScore),1,data)!=1) { printf(" !
"); getch(); exit(0); } p->next=ListHead->next; ListHead->next=p; } else free(p); }while(result==1); if(ListHead->next)printf("
"); else printf("
"); } printf("-----------------------------------
"); printf("
"); getch(); return 1; } int FinishFileWrite(TestUser *ListHead) { FILE *data=fopen("data","wb"); if(ListHead->next) { TestUser *p=ListHead->next; for(;p;p=p->next) { if(fwrite(p,sizeof(TestUser),1,data)!=1) {printf(" !
");break;} if(fwrite(p->score,sizeof(UserScore),1,data)!=1) {printf(" !
");break;} } printf("-----------------------------------
"); printf(" ,
"); } else printf(" ,
"); fclose(data); getch(); return 1; } int main() { TestUser *ListHead=(TestUser *)malloc(sizeof(TestUser)); ListHead->next=NULL; FirstFileRead(ListHead); while(!(InterfacialOutput(ListHead))) InterfacialOutput(ListHead); FinishFileWrite(ListHead); return 0; }