void MainWindow::chTime() { ui->systime->display(QDateTime::currentDateTime().toString("hh:mm:ss"));//屏幕输出当前时间 if(!isclose) { filetimes++;//每过一秒计时一次 if(iswork) { work(); if(filetimes>=10){//每10秒文件输出一次 fileprint(); filetimes=0; } } print();//每秒更新屏幕信息 } else { QMessageBox::information(this,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("营业厅已经下班,即将进入数据统计系统!"),QMessageBox::Yes); this->close(); staticesw staticesw1; staticesw1.exec(); } }
int tablesearch(char* filename,char (*tableindex)[TABLE_NAME_MAX],Column** columnindex,Data*** database) { FILE* file; int isnosearch=0; // Is there no restriction to the column name int colname_print[COL_READ_MAX]; // Store the number of column to print -1 is the end int colname_do[COL_READ_MAX]; // the order os Column to operte -1 is the end char colnameprints[COL_READ_MAX][COLUMN_NAME_MAX];// recieve every columname to print char colvalue[COL_READ_MAX][COLUMN_NAME_MAX]; //recieve evey column_value int colname_order; //the order of column to sort by int colnumber=0; int andor[AND_OR_MAX]; // and or ARRAY or=0 and=1 -1 is the end int likeequal[LIKE_EQUAL_MAX]; //like = Array -1 is the end 0=like 1 = = // char buffer[LINE_MAX]; //Buffer of file int countavalible=0; //Items that has been read int tableoperate; // The order of operting table int countnumber=0; //How Many columns to print int numberofprint=0; //how many lines to print if 0 means all int asc=ASC; if((file=fopen(filename,"r"))==NULL) { printf("Error in opening the file!\n"); return 0; } start=over=(time_t)0; //count the time start=clock(); checkline1(file,colname_print,&numberofprint,colnameprints,&tableoperate ,tableindex,columnindex); if(database[tableoperate] == NULL ) {printf("The table hasn't been Initialized!\n"); return 0;} char *revalue=checkline2(file, andor, likeequal,colvalue,colname_do,tableoperate,columnindex); char* command=revalue; if(command==NULL) { colname_order=0; asc=ASC; } else { if(!mystrcmp(command,"order")) { char buffer[LINE_MAX]; command=getwords(file,buffer); //by if(mystrcmp("by",buffer)) { printf("You should follow order a by\n"); return 0; } command=getwords(file,buffer); //column_name colname_order= columnnow(buffer,tableoperate,columnindex); if(colname_order == -1) {printf("Error in lcating the %s column\n",buffer); return 0; } command=getwords(file,buffer); //ASC DESC or EOF if(command==NULL) asc=ASC; else if(!mystrcmp("ASC",buffer)) asc=ASC; else asc=DESC; } } fclose(file); int *index=CreateIndex(tableoperate,colname_do,colname_order,likeequal,colvalue,andor,columnindex,database); // Create index of table to print int _coltype= columnindex[tableoperate][colname_order].nametype; //Style of data to sort by int numberitems=0; //How many lines to print while( index[numberitems] != -1) numberitems++; shellsort(index ,numberitems,_coltype,asc,database[tableoperate][colname_order]); //Put the result to file and return how many has been searched int countsearch = fileprint("074090_select.txt",numberofprint,colname_print,database[tableoperate],columnindex[tableoperate],index); free(index); //Free the index return countsearch; }
void func1() { char ch; int broi, b, w, snd, m=0, x, t=0, r, f, s, a, i, neww[100]; int str[] = {2, 6, 6, 6, 6, 8, 0, 8, 0, 8, 6, 5, 4, 3, 2, 4, 6, 8, 0, 8, 7, 6, 5, 8, 0, 8, 7, 5, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2, 6, 6, 6, 6, 8, 0, 8, 0, 8, 6, 5, 4, 3, 2, 4, 6, 8, 0, 8, 7, 6, 5, 8, 0, 8, 7, 5, 5, 6, 7, 7, 7, 7, 7, 0, 1, 0, 7, 7, 9, 5, 8, 8, -8, 2, 7, 9, 9, 9}; printf("Zadadeniq masiv e: "); for(i=0; i<100; i++) //printirane na masiva { printf(" %d ",str[i]); } printf("\n"); for(a=str[0],i=0; i<100; i++) //namirane na nai golqmoto 4islo v masiva { if(a<str[i]) { a=str[i]; //a e nai golqmoto 4islo v masiva } } for(b=str[0],i=0; i<100; i++) //namirane na nai malkoto 4islo v masiva { if(b>str[i]) { b=str[i]; //b e nai malkoto 4islo v masiva } } for(i=0;; i++) // namira poziciqta v masiva na purvoto nai golqmo 4islo (ako to se povtarq) { if(a==str[i]) { s=i; break; } } for(i=0,f=s; i<(100-f); i++,s++) //vuvejda 4islata sled nai golqmoto (vklu4itelno) v vtoriq masiv { neww[i]=str[s]; } printf(" \n "); printf("Vtoriqt masiv podreden po golemina: "); for(r=0,i=0; i<(a+1); i++,r++,t=0) //printira vtoriq masiv po golemina polojitelnite i 0 { do { if((a-r)==neww[t]) { printf(" %d ",neww[t]); } if(t==(99-f))break; t++; } while(1); } for(r=1,w=0; w>(b-1); w--,r++,t=0) //printira vtoriq masiv po golemina { do { if((0-r)==neww[t]) { printf(" %d ",neww[t]); } if(t==(99-f))break; t++; } while(1); } for(r=0,x=1; r<1; x++) //namirame vtoroto po golemina 4islo v vtoriq masiv { for(t=0;;) { if((a-x)==neww[t]) { snd=neww[t]; //snd e vtoroto po golemina 4islo v masiv 2 r=1; } if(t==(99-f)) break; t++; } if((a-x)==0) break; } for(broi=0,t=0;;) { if(snd==neww[t]) { broi++; } if(t==(99-f)) break; t++; } printf("\nVtoroto po golemina 4islo ot vtoriq masiv se povtarq %d puti\n",broi); for(i=0,r=8;; r--) { if(i==2) break; if(r<0) break; for(broi=0,t=0;;) { if(r==neww[t]) { broi++; i=2; } if((-r)==neww[t]) { broi++; i=2; } if(t==(99-f)) break; t++; } } for(t=1,i=0; i<100; i++) { if(neww[i]!=neww[i+1]) { t=0; break; } } if(t==1) { printf("\nCifrata s vtori po golemina ANCII cod ot vtoriq masiv e (%d) i se povtarq %d puti\n",r+1,broi); } else { printf("\nVsi4ki cifri v masiva sa ednakvi i nqma vtora po golemina\n"); } printf("Izka6 li da zapi6a masiva v fail (Y or something else)"); fflush(stdin); ch=getche(); if((ch=='y')||(ch=='Y')) { fileprint(neww,f); } }