Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //made with flex(GNU)
- %option noyywrap
- %{
- #include <stdio.h>
- #include <stdlib.h>
- int adminCounter = 0;
- int allCounter = 0;
- %}
- %%
- Admin { printf("Admin"); adminCounter++; allCounter++;}
- User { printf("User"); allCounter++;}
- %%
- int main() {
- printf("\tThis program receives a script\n\t\tand returns a percentage of admin`s messages.\n");
- printf("\n\t\t\t\tScript:\n\n");
- yylex();
- printf("\n\nNumber of all messages: %d\n", allCounter);
- printf("Number of admin`s messages: %d\n", adminCounter);
- float ans;
- ans = ((double)adminCounter / (double)allCounter) * 100;
- printf("Percentage of admin`s messages: %.2f%%\n", ans);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement