Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main()
- {
- float xmin, xmax, x, xch, step, Y;
- int chs, N=1, i, dot, x_prov=0, chs_prov, color, skin, bg, ch_skin, n, txt_color_chs, prov=0, N_next;
- printf(".:: Table builder v1.0 ::.\n\n");
- do {
- prov++;
- if (prov>1) printf("Only digits! And only 1 or 2! \n");
- printf("Do you want to select color skin?(1-yes, 2-no): ");
- fflush(stdin);
- }
- while (!scanf("%d", &color) || color != 1 && color != 2);
- prov=0;
- if (color==1)
- {
- do {
- prov++;
- if (prov>1) printf("Only digits! And only from 1 to 5! \n");
- printf("\nDo you want make skin yourself(enter 1) or select done skin(enter 2)?\nEnter variant number: ");
- fflush(stdin);
- }
- while (!scanf("%d", &ch_skin) || ch_skin != 1 && ch_skin != 2 && ch_skin != 3 && ch_skin != 4 && ch_skin != 5);
- prov=0;
- if (ch_skin==1) {
- printf("\nWellcome to Color Wizard!\n\nFirst step. Select background color:\n1.Black\n2.White\n3.Blue\n4.Bright Grey\n5.Bright Blue\nYour choice: ");
- scanf("%d", &bg);
- switch (bg)
- {
- case 1: system("color 07"); n=1; break;
- case 2: system("color FF"); n=2; break;
- case 3: system("color 17"); n=3; break;
- case 4: system("color 7F"); n=4; break;
- case 5: system("color BF"); n=5; break;
- default: system("color 07"); n=6; printf("Uncorrect answer. Default seted BLACK color"); break;
- }
- printf("\nSecond step. Select text color:\n1.Black\n2.Green\n3.Red\nYour choice: ");
- scanf("%d", &txt_color_chs);
- if (n==1)
- {
- switch (txt_color_chs)
- {
- case 1: system("color 00"); break;
- case 2: system("color 0A"); break;
- case 3: system("color 0C"); break;
- default: system("color 07"); printf("Uncorrect answer. Ddefault seted WHITE color\n"); break;
- }
- }
- else {
- if (n==2)
- {
- switch (txt_color_chs)
- {
- case 1: system("color F0"); break;
- case 2: system("color FA"); break;
- case 3: system("color FC"); break;
- default: system("color F7"); printf("Uncorrect answer. Ddefault seted WHITE color"); break;
- }
- }
- else {
- if (n==3)
- {
- switch (txt_color_chs)
- {
- case 1: system("color 10"); break;
- case 2: system("color 1A"); break;
- case 3: system("color 1C"); break;
- default: system("color 17"); printf("Uncorrect answer. Ddefault seted WHITE color"); break;
- }
- }
- else {
- if (n==4)
- {
- switch (txt_color_chs)
- {
- case 1: system("color 70"); break;
- case 2: system("color 7A"); break;
- case 3: system("color 7C"); break;
- default: system("color 77"); printf("Uncorrect answer. Ddefault seted WHITE color"); break;
- }
- }
- else {
- if (n==5) {
- switch (txt_color_chs)
- {
- case 1: system("color B0"); break;
- case 2: system("color BA"); break;
- case 3: system("color BC"); break;
- default: system("color B7"); printf("Uncorrect answer. Ddefault seted WHITE color"); break;
- }
- }
- else {
- if (n==6) {
- switch (txt_color_chs)
- {
- case 1: system("color 00"); break;
- case 2: system("color 0A"); break;
- case 3: system("color 0C"); break;
- default: system("color 07"); printf("Uncorrect answer. Ddefault seted WHITE color"); break;
- }
- }
- }
- }
- }
- }
- }
- }
- else {
- if (ch_skin==2)
- {
- printf("Select skin:\n\n1.Light grey\n2.Dark red\n3.Like a paper\n\nYour choice: ");
- scanf("%d", &skin);
- switch (skin)
- {
- case 1: system("color 70"); break;
- case 2: system("color 0C"); break;
- case 3: system("color F0"); break;
- default: printf("None of the proposal was not selected.\nWell, program will set default author skin\n");
- system("color 1D"); break;
- }
- }
- }
- }
- do {
- x_prov=0;
- do {
- prov++;
- if (prov>1) printf("Only digits! Try again\n");
- printf("\nEnter Xmin: ");
- fflush(stdin);
- }
- while (!scanf("%f", &xmin));
- prov=0;
- do {
- prov++;
- if (prov>1) printf("Only digits! Try again\n");
- printf("Enter Xmax: ");
- fflush(stdin);
- }
- while (!scanf("%f", &xmax));
- prov=0;
- if (!(xmin<xmax))
- { printf("Xmax must be bigger then Xmin!\n");
- if (xmin>xmax) {
- printf("So program will swaps Xmin & Xmax...");
- xch=xmin;
- xmin=xmax;
- xmax=xch;
- printf("\n Xmin = %.1f\t\n", xmin);
- printf(" Xmax = %.1f\t", xmax);
- }
- else {
- if (xmax==xmin) {
- printf("Enter again plz\n");
- x_prov++;
- }
- }
- }
- }
- while(x_prov>0);
- do {
- prov++;
- if (prov>1) printf("Enter only 1 or 2!");
- printf("\nWhat do you prefer? Dots = 1, Steps = 2\nEnter your choice: ");
- fflush(stdin);
- }
- while (!scanf("%d", &chs) || chs != 1 && chs != 2);
- prov=0;
- if(chs==1)
- {
- do {
- chs_prov=0;
- do { prov++;
- if (prov>1) printf("Only digits! Try again\n");
- printf("Enter dots value: ");
- fflush(stdin);
- }
- while (!scanf("%d", &dot));
- prov=0;
- if (dot==1) { printf("Table with one dot is incorrect! Try again\n"); chs_prov++; } //Work but strange: step=(xmax-xmin)/dot; }
- else {
- if (dot>1) { step=(xmax-xmin)/(dot-1); }
- else {
- if (dot==0) { printf("Table without dots will be empty! Try again\n"); chs_prov++;}
- }
- }
- }
- while (chs_prov>0);
- }
- else
- {
- if(chs==2) {
- do {
- prov++;
- if (prov>1) printf("Only digits!\n");
- printf("\nEnter step value: ");
- fflush(stdin);
- }
- while (!scanf("%f", &step));
- prov=0;
- }
- }
- printf(" %c",201); for (i=0; i<7; i++) {printf("%c", 205);} printf("%c", 203); //High border
- for (i=0; i<=20; i++) {printf("%c", 205);} printf("%c", 203);
- for (i=0; i<=21; i++) {printf("%c", 205);} printf("%c\n", 187);
- printf(" %c",186);
- printf("%6s ", "Xmin:"); printf("%c",186); // nazv xmin
- printf("%20s ", "Xmax:"); printf("%c",186); // nazv Xmax
- printf("%21s ", "Step:"); printf("%c\n",186); // nazv step
- printf(" %c",204); for (i=0; i<7; i++) {printf("%c", 205);} printf("%c", 206); //First underline string
- for (i=0; i<=20; i++) {printf("%c", 205);} printf("%c", 206);
- for (i=0; i<=21; i++) {printf("%c", 205);} printf("%c\n", 185);
- printf(" %c",186);
- printf("%6.2f ", xmin); printf("%c",186); // xmin
- printf("%20.2f ", xmax); printf("%c",186); // xmax
- printf("%21.2f ", step); printf("%c\n",186); // step
- printf(" %c",204); for (i=0; i<7; i++) {printf("%c", 205);} printf("%c", 206); //Second underline string
- for (i=0; i<=20; i++) {printf("%c", 205);} printf("%c", 206);
- for (i=0; i<=21; i++) {printf("%c", 205);} printf("%c\n", 185);
- printf(" %c",186);
- printf("%6s ", "N:"); printf("%c",186); // N
- printf("%20s ", "X:"); printf("%c",186); // X
- printf("%21s ", "Y:"); printf("%c\n",186); // Y
- printf(" %c",204); for (i=0; i<7; i++) {printf("%c", 205);} printf("%c", 206); //Third underline string
- for (i=0; i<=20; i++) {printf("%c", 205);} printf("%c", 206);
- for (i=0; i<=21; i++) {printf("%c", 205);} printf("%c\n", 185);
- for(x=xmin; x<=xmax; x=x+step) // MAIN CYCLE
- {
- printf(" %c",186); printf("%6i ", N);
- N++;
- printf("%c",186); // val N
- printf("%20.2f ", x); printf("%c",186); // val X
- Y=pow(x,2)-5*x+3; printf("%21.2f ", Y); printf("%c\n",186); // val Y
- printf(" %c",204); for (i=0; i<7; i++) {printf("%c", 205);} printf("%c", 206);
- for (i=0; i<=20; i++) {printf("%c", 205);} printf("%c", 206);
- for (i=0; i<=21; i++) {printf("%c", 205);} printf("%c\n", 185);// Underline string
- if (x==xmax) {
- printf(" %c",200); for (i=0; i<7; i++) {printf("%c", 205);} printf("%c", 202);
- for (i=0; i<=20; i++) {printf("%c", 205);} printf("%c", 202); //Last underline string
- for (i=0; i<=21; i++) {printf("%c", 205);} printf("%c\n", 188);
- }
- if (x>xmax-step)
- {
- if (xmax>x)
- {
- printf(" %c",200); for (i=0; i<7; i++) {printf("%c", 205);} printf("%c", 202);
- for (i=0; i<=20; i++) {printf("%c", 205);} printf("%c", 202); //Last undr prov
- for (i=0; i<=21; i++) {printf("%c", 205);} printf("%c\n", 188);
- }
- }
- if (N==10)
- {
- N_next=0;
- }
- if (N_next%12==0)
- {
- system("PAUSE"); system("cls");
- }
- N_next++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement