Created
October 20, 2010 08:48
-
-
Save Levik/636053 to your computer and use it in GitHub Desktop.
ifelse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <conio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| void main() | |
| { | |
| int a[10], b, d; | |
| char c[3]; | |
| srand(time(NULL)); | |
| clrscr(); | |
| do | |
| { | |
| printf("random? 0/1 \n"); | |
| scanf("%d", &b); | |
| for (int j=0;j<10;j++) | |
| { | |
| if (b==1) | |
| a[j]=rand()%10; | |
| else if (b==0) | |
| scanf("%d", &a[j]); | |
| } | |
| } while (b=!(0||1)); | |
| clrscr(); | |
| i: | |
| printf("vvedite uslovie "); | |
| scanf("%s", &c); | |
| for (int i=0;i<10;i++) | |
| { | |
| if (strcmp(c, "==") == 0) | |
| { | |
| do | |
| { | |
| printf("vvedite 4islo "); | |
| scanf("%d", &d); | |
| } while (!d>-32768&&!d<32767); | |
| if (a[i]==d) | |
| printf("%d \n", a[i]); | |
| } else if (strcmp(c, "!=") == 0) | |
| { | |
| do | |
| { | |
| printf("vvedite 4islo "); | |
| scanf("%d", &d); | |
| } while (!d>-32768&&!d<32767); | |
| if (a[i]!=d) | |
| printf("%d \n", a[i]); | |
| } else if (strcmp(c, ">=") == 0) | |
| { | |
| do | |
| { | |
| printf("vvedite 4islo "); | |
| scanf("%d", &d); | |
| } while (!(d>-32768&&d<32767)); | |
| if (a[i]>=d) | |
| printf("%d \n", a[i]); | |
| } else if (strcmp(c, "<=") == 0) | |
| { | |
| do | |
| { | |
| printf("vvedite 4islo "); | |
| scanf("%d", &d); | |
| } while (!d>-32768&&!d<32767); | |
| if (a[i]<=d) | |
| printf("%d \n", a[i]); | |
| } else | |
| goto i; | |
| } | |
| getch(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment