// merge the priority queue h1 and h2. PriorityQueue innerMerge(PriorityQueue h1, PriorityQueue h2) { if(h1->left == NULL) { h1->left = h2; } else { h1->right = merge(h1->right, h2); } // update the null path length if(h1->right == NULL) { h1->nullPathLen = 0; } else { h1->nullPathLen = minimal(h1->left->nullPathLen, h1->right->nullPathLen) + 1; // exchange the left and the right if(h1->left->nullPathLen < h1->right->nullPathLen) { swap(h1); } } return h1; }
Node* Node::successor() {//Następnik Node *p = this; if (this->right != NULL) return(minimal(p->right)); throw std::exception("Wezel nie posiada nastepnika."); };
int main (int argc, char** argv) { printf("Just testing the build system!\n"); minimal(); #ifdef ALPHA alpha(); #endif return EXIT_SUCCESS; }
Node* successor(Node* no) { if (no == NULL) return NULL; /* if node has right child, then the successor is the leftest leaf node of the right child tree */ if (no->rchild) return minimal(no->rchild); /* otherwise the successor is the closet ancestor node whose left child tree contains node */ Node* y = no->parent; while (y && y->rchild == no) { no == y; y = y->parent; } return y; }
node* minimal(node *tree){ if(tree==NULL){ return NULL; } if(tree->left) return minimal(tree->left); else return tree; }
////////////////////////// // Receive ASCII (term) ////////////////////////// bool CMimeProtocol::receive(int link,char *pszBuffer,int nMaxSize,char *pszTerminator) { char szTmpBuffer[CBUFF_MASSIVE]; char *pszTerm; int nBytes = 0; int nReceived = 0; // Reset strcpy(pszBuffer,""); // Forever while(!(pszTerm = strstr(pszBuffer,pszTerminator))){ // Receive bytes from socket //nBytes = recvTcp(link,&szTmpBuffer[nReceived],nMaxSize-nReceived); nBytes = recvTcp(link,&pszBuffer[nReceived],nMaxSize-nReceived); if(nBytes == -1){ if(OSALASTERROR != OSAWOULDBLOCK) return false; OSASleep(5); continue; } // Check for end if(nBytes == 0 || nBytes == -1) return false; // Check for error if(nBytes <= -1) return false; // Copy data szTmpBuffer[nBytes] = 0; // Check limits if(nReceived + nBytes >= nMaxSize) return false; nReceived += nBytes; } // Success (remove terminator) pszBuffer[minimal(nReceived,nMaxSize)]=0; //*pszTerm = 0; return true; }
int nthUglyNumber::nthUglyNumber1(int n) { int* arr=(int*)malloc(sizeof(int)*n); int index_2=0,index_3=0,index_5=0; int val_2=2, val_3=3, val_5=5; arr[0]=1; for(int i=1;i<n;i++){ arr[i]=minimal(val_2,val_3,val_5); cout<<val_2<<","<<val_3<<","<<val_5<<"-----"; if(arr[i]==val_2) val_2=arr[++index_2]*2; if(arr[i]==val_3) val_3=arr[++index_3]*3; if(arr[i]==val_5) val_5=arr[++index_5]*5; cout<<val_2<<","<<val_3<<","<<val_5<<endl; } return arr[n-1]; }
/** * @brief Résout un puzzle * @param[in,out] p le puzzle à résoudre * @param[in] t le damier initial * @param[in,out] os flux de sortie */ void jouer(Puzzle& p, const Tab2D& t, std::ostream& os) { Etat etatInitial; Etat etatCourant; Tab2D damierFinal; Etat etatDerive; double tempsDebutRecherche = getTime(); but(damierFinal, t.nbL, t.nbC); initialiser(etatInitial.damier, t.nbL, t.nbC); etatInitial.mouvement = FIXE; etatInitial.precedent = 0; etatInitial.g = 0; //Copie du damier inititial dans etatInitial for (unsigned int l = 0; l < t.nbL; ++l) { for (unsigned int c = 0; c < t.nbC; ++c) { etatInitial.damier.tab[l][c] = t.tab[l][c]; } } etatInitial.h = manhattan(etatInitial.damier, damierFinal); initialiser(etatDerive.damier, t.nbL, t.nbC); inserer(p.lEAE, 0, etatInitial); //étatInitial dans LEAE bool solutionTrouvee = false; bool mvtPossible; unsigned int pos; while (p.lEAE.nb != 0) { pos = minimal(p.lEAE); etatCourant = lire(p.lEAE, pos); //on prend le 1er état à explorer //insérer étatCourant dans LEE inserer(p.lEE, longueur(p.lEE), etatCourant); supprimer(p.lEAE, pos); //supprimer étatCourant de LEAE if (etatCourant.h == 0) { // le damier de étatCourant est le damier but solutionTrouvee = true; break; //sortir de la boucle while } /*pour_tout (mouvement possible associé à étatCourant) mouvement possible relatif à damier de étatCourant (etatCourant.damier) ordre d'exploration (obligatoire) NORD, EST, SUD, OUEST */ //initialiser un étatDérivé // d'après le mouvement for(int m = OUEST; m >= NORD; --m) { mvtPossible = deriver(etatCourant, (Mouvement) m, etatDerive); if (mvtPossible && !rechercher(etatDerive, p.lEAE)\ && !rechercher(etatDerive, p.lEE)) { etatDerive.precedent = longueur(p.lEE) - 1; etatDerive.h = manhattan(etatDerive.damier, damierFinal); etatDerive.g = etatCourant.g + 1; //insérer étatDérivé dans LEAE inserer(p.lEAE, longueur(p.lEAE), etatDerive); } } } double tempsFinRecherche = getTime(); cout << "Durée de recherche : " << tempsFinRecherche - tempsDebutRecherche <<" seconde(s)."<< endl; if (solutionTrouvee) { Pile sol; Etat etatSol; initialiser(sol, 3, 2); initialiser(etatSol.damier, t.nbL, t.nbC); //Stockage de la solution etatSol = lire(p.lEE, longueur(p.lEE)-1); empiler(sol, etatSol); while (etatSol.precedent != 0) { etatSol = lire(p.lEE, etatSol.precedent); empiler(sol, etatSol); } empiler(sol, etatInitial); //Affichage de la solution os << "Damier : " << t.nbL << " lignes " << t.nbC << " colonnes" << endl; os << "Solution en " << sol.sommet << " mouvements" << endl; while (!estVide(sol)) { afficher(sommet(sol), os); os << endl; depiler(sol); } detruire(sol); detruire(etatSol.damier); } else { os << "Solution non trouvée" << endl; } detruire(etatInitial.damier); detruire(etatCourant.damier); detruire(etatDerive.damier); detruire(damierFinal); }
/* create mesh from a vector of nodes, element list in format => * {nuber of nodes, node0, node1, ..., material}, {REPEAT}, ..., 0 (end of list); and surface colors in format => * global surface, {number of nodes, node0, node1, ..., surface}, {REPEAT}, ..., 0 (end of list); */ MESH_DATA* MESH_Create (REAL (*nodes) [3], int *elements, int *surfaces) { int maximal_node, minimal_node, elements_count, faces_count, temp, *eleptr, n; REAL (*node) [3]; MEM *elemem, facmem, mapmem; ELEMENT *ele, *enx, *elist; FACE *fac, *cac, *gac, *flist; MAP *faces, *smap; MESH_DATA *msh; maximal_node = 0; minimal_node = INT_MAX; elements_count = 0; faces_count = 0; /* create mesh storage */ ERRMEM (msh = static_cast<MESH_DATA*>(MEM_CALLOC (sizeof (MESH_DATA)))); elemem = &msh->elemem; /* calculate elements */ for (eleptr = elements; eleptr [0]; eleptr += (eleptr [0]+2)) elements_count ++; MEM_Init (elemem, sizeof (ELEMENT), elements_count); MEM_Init (&facmem, sizeof (FACE), MEMCHUNK); MEM_Init (&mapmem, sizeof (MAP), MEMCHUNK); MEM_Init (&msh->mapmem, sizeof (MAP), MIN (elements_count, MEMCHUNK)); elist = NULL; flist = NULL; faces = NULL; /* create elements list & face adjacency map */ for (eleptr = elements; eleptr [0]; eleptr += (eleptr [0]+2)) { ASSERT ( eleptr [0] == 4 || /* tetrahedron */ eleptr [0] == 5 || /* pyramid */ eleptr [0] == 6 || /* wedge */ eleptr [0] == 8, /* hexahedron */ "ERROR: unsupported element type"); ele = create_element (elemem, eleptr); flist = create_faces (&facmem, &mapmem, &faces, ele, flist); ele->next = elist; elist = ele; /* node number extrema */ temp = maximal (eleptr); if (temp > maximal_node) maximal_node = temp; temp = minimal (eleptr); if (temp < minimal_node) minimal_node = temp; } /* calculate faces */ for (fac = flist; fac; fac = fac->next) if (fac->ele) faces_count ++; /* alocate additional storage */ MEM_Init (&msh->facmem, sizeof (FACE), faces_count); msh->nodes_count = (maximal_node - minimal_node + 1); ERRMEM (msh->nodes = static_cast<REAL(*)[3]>(malloc (sizeof (REAL [3]) * (msh->nodes_count)))); msh->surfeles_count = msh->bulkeles_count = 0; msh->surfeles = msh->bulkeles = NULL; /* set up elements */ for (ele = elist; ele; ele = enx) { enx = ele->next; if (minimal_node > 0) /* impose 0-based indexing */ { for (temp = 0; temp < ele->type; temp ++) ele->nodes [temp] -= minimal_node; } ele->prev = NULL; if (ele->neighs < neighs (ele->type)) /* surface element */ { msh->surfeles_count ++; ele->next = msh->surfeles; if (msh->surfeles) msh->surfeles->prev = ele; msh->surfeles = ele; } else /* bulk element */ { msh->bulkeles_count ++; ele->next = msh->bulkeles; if (msh->bulkeles) msh->bulkeles->prev = ele; msh->bulkeles = ele; } } /* create surfaces map => skip first element of 'surfaces' == the global surface kind */ for (eleptr = (surfaces + 1), smap = NULL, temp = 0; eleptr [0]; eleptr += (eleptr [0]+2), temp ++) { fac = static_cast<FACE*>(MEM_Alloc (&facmem)); ASSERT ( eleptr [0] == 3 || /* triangle */ eleptr [0] == 4, /* quad */ "ERROR: unsupported face type"); fac->type = eleptr [0]; for (n = 0; n < eleptr [0]; n ++) fac->nodes [n] = eleptr [n+1]; sort (fac->nodes, fac->nodes+fac->type-1); fac->color = eleptr [eleptr [0] + 1]; MAP_Insert (&mapmem, &smap, fac, /* map by the type/nodes key */ fac, face_compare); } /* set up nodes */ for (temp = minimal_node, node = msh->nodes; temp <= maximal_node; temp ++, node ++) { COPY (nodes [temp], *node); } /* set up faces */ for (fac = flist; fac; fac = fac->next) { if (fac->ele) /* see (***) */ { ele = fac->ele; cac = static_cast<FACE*>(MEM_Alloc (&msh->facmem)); setup_face (ele, fac->index, cac, 0); /* setup face nodes without sorting them */ cac->index = fac->index; cac->ele = fac->ele; setup_normal (msh->nodes, cac); /* calculate outer spatial normal */ cac->next = ele->faces; /* append element face list */ ele->faces = cac; /* set the mapped surface kind if possible => otherwise the global one */ gac = static_cast<FACE*>(MAP_Find (smap, fac, face_compare)); cac->color = (gac ? gac->color : surfaces [0]); } } /* create mesh face list */ for (ele = msh->surfeles; ele; ele = ele->next) { for (fac = ele->faces; fac; fac = fac->next) { fac->n = msh->faces; msh->faces = fac; } } /* clean up */ MEM_Release (&facmem); MEM_Release (&mapmem); return msh; }
int main (void) { int elemc; int Aqua; int red, Red; int greenForeground; int Standart; int greenBackground = FOREGROUND_GREEN | FOREGROUND_INTENSITY; Red = FOREGROUND_RED | FOREGROUND_INTENSITY; red = FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY; Standart = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN; Aqua = BACKGROUND_GREEN | BACKGROUND_BLUE ; greenForeground = BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); COORD pos; START:; for(pos.Y = 0; pos.Y < 40 ;pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } for(pos.Y = 7; pos.Y <= 19; pos.Y+=12 ) { for(pos.X = 20; pos.X <= 59; pos.X++ ) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Aqua); puts("="); } } for(pos.Y = 8; pos.Y < 19; pos.Y++) { for(pos.X = 20; pos.X <= 58; pos.X++) { if(pos.X == 20 || pos.X == 58) { SetConsoleCursorPosition(hConsole, pos); puts("||"); } } } for(pos.Y = 8; pos.Y < 19; pos.Y++) { for(pos.X = 22; pos.X < 58; pos.X++) { SetConsoleCursorPosition(hConsole, pos); puts(" "); } } SetConsoleTextAttribute(hConsole, greenForeground); for(pos.Y = 10; pos.Y <= 12; pos.Y++) { pos.X = 26; if(pos.Y == 10) { SetConsoleCursorPosition(hConsole, pos); printf(" Vvedite razmer odnommernogo"); } if(pos.Y == 11) { SetConsoleCursorPosition(hConsole, pos); printf(" massiva drobovix chisel::"); } if(pos.Y == 12) { SetConsoleCursorPosition(hConsole, pos); printf("\t [1....100]"); } } pos.Y = 14; pos.X = 39; SetConsoleCursorPosition(hConsole, pos); scanf("%i", &elemc); if(elemc < 1 || elemc > 100){ SetConsoleTextAttribute(hConsole, red); pos.X = 28; pos.Y = 16; SetConsoleCursorPosition(hConsole, pos); printf("Invalid input, try again"); Sleep(4000); goto START; } /*for(;elemc < 1 || elemc > 100;) { SetConsoleTextAttribute(hConsole, red); pos.X = 28; pos.Y = 16; SetConsoleCursorPosition(hConsole, pos); printf("Invalid input, try again"); for(pos.Y = 14, pos.X = 38; pos.X <58; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Aqua); puts(" "); } pos.Y = 14; pos.X = 39; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, greenForeground); scanf("%i", &elemc); }*/ for(pos.Y = 0; pos.Y < 30; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleTextAttribute(hConsole, Standart); SetConsoleCursorPosition(hConsole, pos); puts(" "); } for(pos.Y = 0; pos.Y < 15; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { if(pos.Y == 0 || pos.Y == 14) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Aqua); puts("="); }else { SetConsoleCursorPosition(hConsole, pos); puts(" "); } } srand(time(NULL)); double arr[elemc]; pos.X = 0; pos.Y = 1; SetConsoleCursorPosition(hConsole, pos); arrrand(arr, elemc); int j; for(j = 0; j < elemc; j++) { printf("%10.3f", arr[j]); } METKA:; SetConsoleTextAttribute(hConsole, Standart); for(pos.Y = 16; pos.Y < 35; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); puts(" "); } pos.X = 0; pos.Y = 16; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, greenBackground); printf("Enter your comand:\n>>"); SetConsoleTextAttribute(hConsole, Standart); char comand[100] = {0}; scanf("%s", &comand); if(comand[12] != 0) { SetConsoleTextAttribute(hConsole, Red); printf("INVALID COMMAND, ENTER !!help!! TO GET THE LIST OF COMMANDS !!!"); Sleep(3000); goto METKA; } if (comand[0] == 'h') if(comand[1] == 'e') if(comand[2] == 'l') if(comand[3] == 'p') { printf("\t\tcommand list:::\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\treset "); SetConsoleTextAttribute(hConsole, Standart); printf("obnulyaet vse elementi massiva\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tchange "); SetConsoleTextAttribute(hConsole, Standart); printf("izmenit element massiva na vvedennoe znachenie\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\trandom "); SetConsoleTextAttribute(hConsole, Standart); printf("Zapolnaet maasiv chislami v zadanom diapozone\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tbackorder "); SetConsoleTextAttribute(hConsole, Standart); printf("Vivodit masiv v obratnom poryadke\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tsum "); SetConsoleTextAttribute(hConsole, Standart); printf("Vivodit sumu elementov masiva\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tnegnumber "); SetConsoleTextAttribute(hConsole, Standart); printf("Vivodit kolvo otrizatelnix elementov\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\texit "); SetConsoleTextAttribute(hConsole, Standart); printf("finish the programm\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\trestart "); SetConsoleTextAttribute(hConsole, Standart); printf("perezapusk programmi\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tpower "); SetConsoleTextAttribute(hConsole, Standart); printf("podnosit vse elementi massiva v zadanuj stepen\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tminimal "); SetConsoleTextAttribute(hConsole, Standart); printf("Vivodit minimalnii element i ego index\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tmaxminchange "); SetConsoleTextAttribute(hConsole, Standart); printf("Menayet max i min element mestami\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tsimpleshift "); SetConsoleTextAttribute(hConsole, Standart); printf("Sdvigaet masiv vpravo na vedenoe kolvo elementov\n"); SetConsoleTextAttribute(hConsole, Red); printf("\t\tcircleshift "); SetConsoleTextAttribute(hConsole, Standart); printf("ziklichno sdvigaet masive vpravo \n"); Sleep(10000); goto METKA; } if (comand[0] == 'r') if(comand[1] == 'e') if(comand[2] == 's') if(comand[3] == 'e') if(comand[4] == 't') { reset(arr, elemc); goto METKA; } if (comand[0] == 'c') if(comand[1] == 'h') if(comand[2] == 'a') if(comand[3] == 'n') if(comand[4] == 'g') if(comand[5] == 'e') { int position; double number; CHANGE:; for(pos.Y = 18; pos.Y < 20; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } pos.Y = 18; pos.X = 0; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); printf("Enter the number of element that you whant to change:: "); scanf("%i", &position); if (position < 0 || position > elemc) { SetConsoleTextAttribute(hConsole, Red); printf("ERROR; Invalid input,plz enter [1...%d]", elemc); Sleep(4000); goto CHANGE; } CHANGE2:; for(pos.Y = 19; pos.Y < 21; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } pos.Y = 19; pos.X = 0; SetConsoleCursorPosition(hConsole, pos); printf("Enter the number on which you want to change:: "); scanf("%lf", &number); if(number > 999999.999 || number < -999999.999) { SetConsoleTextAttribute(hConsole, Red); printf("ERROR; Invalid input,plz enter [-999999.999...999999.999]"); Sleep(4000); goto CHANGE2; } change(arr, elemc, position, number); goto METKA; } if (comand[0] == 'r') if(comand[1] == 'a') if(comand[2] == 'n') if(comand[3] == 'd') if(comand[4] == 'o') if(comand[5] == 'm') { double max, min; RANDOM:; for(pos.Y = 18; pos.Y < 20; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } pos.Y = 18; pos.X = 0; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); printf("Enter the max number of diapozon:: "); scanf("%lf", &max); if(max > 99999.999 || max < -9999.999) { SetConsoleTextAttribute(hConsole, Red); printf("ERROR; Invalid input,plz enter [-999999.999...999999.999]"); Sleep(4000); goto RANDOM; } RANDOM2:; for(pos.Y = 19; pos.Y < 21; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } pos.Y = 19; pos.X = 0; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); printf("Enter the min number of diapozon:: "); scanf("%lf", &min); if(min > 99999.999 || min < -9999.999 || min > max) { SetConsoleTextAttribute(hConsole, Red); printf("ERROR; Invalid input,plz enter [-9999.999...%f]", max); Sleep(4000); goto RANDOM2; } random(arr, elemc, max, min); SetConsoleTextAttribute(hConsole, Aqua); pos.X = 0; pos.Y = 1; SetConsoleCursorPosition(hConsole, pos); for(j = 0; j < elemc; j++) printf("%10.3f", arr[j]); goto METKA; } if (comand[0] == 'b') if(comand[1] == 'a') if(comand[2] == 'c') if(comand[3] == 'k') if(comand[4] == 'o') if(comand[5] == 'r') if (comand[6] == 'd') if(comand[7] == 'e') if(comand[8] == 'r') { backorder(arr, elemc); pos.X = 0; pos.Y = 1; SetConsoleTextAttribute(hConsole, Aqua); SetConsoleCursorPosition(hConsole, pos); for(int l = 0; l < elemc; l++) printf("%10.3f", arr[l]); goto METKA; } if (comand[0] == 's') if(comand[1] == 'u') if(comand[2] == 'm') { SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN); printf("SUMMA = %f", sum(arr, elemc)); Sleep(5000); for(pos.Y = 18; pos.Y < 20; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } goto METKA; } if (comand[0] == 'n') if(comand[1] == 'e') if(comand[2] == 'g') if(comand[3] == 'n') if(comand[4] == 'u') if(comand[5] == 'm') if (comand[6] == 'b') if(comand[7] == 'e') if(comand[8] == 'r') { SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN); printf("KOLVO = %i", negnumber(arr, elemc)); Sleep(5000); for(pos.Y = 18; pos.Y < 20; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } goto METKA; } if (comand[0] == 'e') if(comand[1] == 'x') if(comand[2] == 'i') if(comand[3] == 't') { SetConsoleTextAttribute(hConsole, Standart); printf("\n\n\n\n\n\n\n\n"); return 0; } if (comand[0] == 's') if(comand[1] == 'i') if(comand[2] == 'm') if(comand[3] == 'p') if(comand[4] == 'l') if(comand[5] == 'e') if (comand[6] == 's') if(comand[7] == 'h') if(comand[8] == 'i') if(comand[9] == 'f') if(comand[10] == 't') { int shift; SHIFT:; for(pos.Y = 18; pos.Y < 20; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } pos.Y = 18; pos.X = 0; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); printf("Enter number on how many positions you want to shift masive :: "); scanf("%i", &shift); if(shift < 0 || shift > elemc) { SetConsoleTextAttribute(hConsole, Red); printf("ERROR; Invalid input,plz enter [0...%i]", elemc); Sleep(4000); goto SHIFT; } simpleshift(arr, elemc, shift); SetConsoleTextAttribute(hConsole, Aqua); pos.X = 0; pos.Y = 1; SetConsoleCursorPosition(hConsole, pos); for(j = 0; j < elemc; j++) { printf("%10.3f", arr[j]); } goto METKA; } if (comand[0] == 'c') if(comand[1] == 'i') if(comand[2] == 'r') if(comand[3] == 'c') if(comand[4] == 'l') if(comand[5] == 'e') if (comand[6] == 's') if(comand[7] == 'h') if(comand[8] == 'i') if(comand[9] == 'f') if(comand[10] == 't') { int shift2; SHIFT2:; for(pos.Y = 18; pos.Y < 20; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } pos.Y = 18; pos.X = 0; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); printf("Enter number on how many positions you want to shift masive :: "); scanf("%i", &shift2); if(shift2 < 0 || shift2 > 9999 ) { SetConsoleTextAttribute(hConsole, Red); printf("ERROR; Invalid input,plz enter [0...9999]"); Sleep(4000); goto SHIFT2; } circleshift(arr, elemc, shift2); SetConsoleTextAttribute(hConsole, Aqua); pos.X = 0; pos.Y = 1; SetConsoleCursorPosition(hConsole, pos); for(j = 0; j < elemc; j++) { printf("%10.3f", arr[j]); } goto METKA; } if (comand[0] == 'p') if(comand[1] == 'o') if(comand[2] == 'w') if(comand[3] == 'e') if(comand[4] == 'r') { printf("Enter the power in which you want to up numbers:: "); double numbeR; scanf("%lf", &numbeR); myPower(arr, elemc, numbeR); SetConsoleTextAttribute(hConsole, Aqua); pos.X = 0; pos.Y = 1; SetConsoleCursorPosition(hConsole, pos); for(j = 0; j < elemc; j++) printf("%10.3f", arr[j]); goto METKA; } if (comand[0] == 'r') if(comand[1] == 'e') if(comand[2] == 's') if(comand[3] == 't') if(comand[4] == 'a') if(comand[5] == 'r') if (comand[6] == 't') { goto START; } if (comand[0] == 'm') if(comand[1] == 'i') if(comand[2] == 'n') if(comand[3] == 'i') if(comand[4] == 'm') if(comand[5] == 'a') if (comand[6] == 'l') { int minIndex = minimal(arr, elemc); SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN); printf("Minimal element = %10.3f\nindex of this elenet = %i", arr[minIndex], minIndex); Sleep(5000); for(pos.Y = 18; pos.Y < 21; pos.Y++) for(pos.X = 0; pos.X < 80; pos.X++) { SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, Standart); puts(" "); } goto METKA; } if (comand[0] == 'm'){ if(comand[1] == 'a') if(comand[2] == 'x') if(comand[3] == 'm') if(comand[4] == 'i') if(comand[5] == 'n') if(comand[6] == 'c') if(comand[7] == 'h') if(comand[8] == 'a') if(comand[9] == 'n') if(comand[10] == 'g') if(comand[11] == 'e') { maxtomin(arr, elemc); SetConsoleTextAttribute(hConsole, Aqua); pos.X = 0; pos.Y = 1; SetConsoleCursorPosition(hConsole, pos); for(j = 0; j < elemc; j++) { if(j == maxindex(arr, elemc) || j == minindex(arr, elemc) ) SetConsoleTextAttribute(hConsole, red); printf("%10.3f", arr[j]); SetConsoleTextAttribute(hConsole, Aqua); } goto METKA; } } else { SetConsoleTextAttribute(hConsole, Red); printf("INVALID COMMAND, ENTER !!help!! TO GET THE LIST OF COMMANDS !!!"); Sleep(3000); goto METKA; } SetConsoleTextAttribute(hConsole, Standart); printf("\n\n\n\n\n\n\n\n\n\n"); return 0; }