All pastes #270668 Raw Edit

Untitled

public text v1 · immutable
·published 2006-12-07 16:32 UTC
rendered paste body
#include <ncurses.h>
#include <string.h> 
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

 bannerf(){
 	int col;
   attron(COLOR_PAIR(2));
	mvprintw(1,6,"                              _     _                              ",NULL);
	mvprintw(2,6,"                            o' \\,=./ `o                            ",NULL);
	mvprintw(3,6,"                               (o o)                               ",NULL);
	mvprintw(4,6,"---------------------------ooO--(_)--Ooo---------------------------",NULL);
   attroff(COLOR_PAIR(2));
	mvprintw(5,6," ____ ____ ____ ____ ____  ____ ____ ____ ____ ____ ____ ____ ____  ",NULL);
	mvprintw(6,6,"||q |||u |||i |||z |||  ||||i |||t |||a |||l |||i |||a |||n |||o ||",NULL);
	mvprintw(7,6,"||__|||__|||__|||__|||__||||__|||__|||__|||__|||__|||__|||__|||__||",NULL);
	mvprintw(8,6,"|/__\\|/__\\|/__\\|/__\\|/__\\||/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|",NULL);
	mvprintw(9,6,"               ____ ____ ____ ____ ____ ____ ____ ____             ",NULL);
	mvprintw(10,6,"              ||             by ttye0                ||            ",NULL);
	mvprintw(11,6,"              ||_____________________________________||          ",NULL);
	mvprintw(12,6,"              |/_____________________________________\\|         ",NULL);
 	}

main(int argc, char *argv[])
{
	double r, x;

	long int nouns=9;
	long int verbs=21;
	long int adjectives=9;
	long int articles=5;
	long int adverbs=10;
	long int pronouns=15;
	long int phrases=24;
	long int conjunctions=8;
	long int prepositions=9;
	long int M=0;
	long int secint=0;	
	
	int y,count,loopnum=10,wrong=0,right=0,ra,alignint,row,col;
	srand(time(0));
	char ans[50],sec[10],*qtype[50],*atype[50];

	const char *qnouns[]={"male","paura","lavoro","gente","ombrello","ombrelli","amici","amico","tempo"};
	const char *anouns[]={"evil","fear","work","people","umbrella","umbrellas","friends","friend","time"};
	const char *qverbs[]={"io sono","tu sei","e\'","noi siamo","voi siete","essi sono","guardare","vedere","io vedo","tu vedi","io ho","avere","io vado","fottere","tu conosci","io conosco","piacere","io dico","dire","io parlo","io voglio"};
	const char *averbs[]={"i am","you are","he is","we are","you are","they are","to watch","to see","i see","you see","i have","to have","i go","to fuck","you know","i know","to like","i say","to say","i speak","i want"};
	const char *qadjectives[]={"stupido","alto","tutto","esatto","solo","inglese","stanca","felice","migliore"};
	const char *aadjectives[]={"stupid","high","all","right","only","english","tired","glad","better"};
	const char *qarticles[]={"la","le","il","gli","lo"};
	const char *aarticles[]={"the","the","the","the","the"};
	const char *qadverbs[]={"ieri","po\'","male","poi","qui","perche\'","li\'","esattemente","piu\'","un poco"};
	const char *aadverbs[]={"yesterday","a bit","badly","then","here","why","there","exactly","more","a little"};
	const char *qpronouns[]={"lui","lei","esso","io","tutto","tutti","tu capisci","niente","quello","questo","questi","questa","se","che","chi"};
	const char *apronouns[]={"he","she","it","i","everyone","everyones","you understand","nothing","that","this","these","this","if","that","who"};
	const char *qphrases[]={"lei e\' figa","stammi bene","aiuto grande","che stai facendo","io sto guardando","fanculo","fottiti","mi dispiace","sono dispiaciuto","ti penso sempre","mi manchi","come sei bella","voglio venderti stasera","tu sei una stella, la mia stella","mia cara, ti amo","mi sei mancata","sei un mangia merda","tu parli inglese","c\'e\'","ci sono","loro sono","questo mi rende felice","devo ricordarlo","amerei"};
	const char *aphrases[]={"she is cool","stay well","great aid","what are you doing","i am watching","fuck off","fuck you","i am sorry","i always think of you","i miss you","how beautiful you are","i want to see you tonight","you are my star, my star","my darling, i love you","i missed you","you are a shit eater","you speak english","there is","there are","they are","that makes me happy","i have to remember that","i would love"};
	const char *qconjunctions[]={"e","ma","perche\'","anche","che","quando","dove","cosa"};
	const char *aconjunctions[]={"and","but","because","also","that","when","where","what"};
	const char *qprepositions[]={"di","a","da","in","con","su","per","tra","fra"};
	const char *aprepositions[]={"of","to","by","in","with","on","for","between","between"};

 initscr();
 start_color();
 use_default_colors();
 init_pair(1, COLOR_YELLOW, -1);
 init_pair(2, COLOR_GREEN, -1);
 init_pair(3, COLOR_RED, -1);
 getmaxyx(stdscr,row,col);
 alignint = (col-strlen("Question #00 (00 of 00) "))/2;

	wborder(stdscr, 0, 0, 0, 0, 0, 0, 0, 0);
	bannerf();
   attron(COLOR_PAIR(1));
	mvprintw((row/2)+2,(col-strlen("Main Menu"))/2,"Main Menu",y,count+1,loopnum);
	mvprintw((row/2)+3,(col-strlen("------------------------------"))/2,"------------------------------",NULL);
   attroff(COLOR_PAIR(1));
	mvprintw((row/2)+4,(col-strlen("3. Adjectives  8. Conjunctions"))/2,"1. Nouns       6. Pronouns",NULL);
	mvprintw((row/2)+5,(col-strlen("3. Adjectives  8. Conjunctions"))/2,"2. Verbs       7. Phrases",NULL);
	mvprintw((row/2)+6,(col-strlen("3. Adjectives  8. Conjunctions"))/2,"3. Adjectives  8. Conjunctions",NULL);
	mvprintw((row/2)+7,(col-strlen("3. Adjectives  8. Conjunctions"))/2,"4. Articles    9. Prepositions",NULL);
	mvprintw((row/2)+8,(col-strlen("3. Adjectives  8. Conjunctions"))/2,"5. Adverbs     0. Quit",NULL);
	mvprintw((row/2)+10,(col-strlen("3. Adjectives  8. Conjunctions"))/2,"Pick a quiz: ",NULL);
	refresh();
	getstr(sec);
	secint = strtol(sec,NULL,0);

	if (secint == 1){
	M = nouns;
		for (count=0; count < nouns; count++){
		memcpy(atype, anouns, sizeof(char *) * 50);
		memcpy(qtype, qnouns, sizeof(char *) * 50);
		}}
	if (secint == 2){
	M = verbs;
		for (count=0; count < verbs; count++){
		memcpy(atype, averbs, sizeof(char *) * 50);
		memcpy(qtype, qverbs, sizeof(char *) * 50);
		}}
	if (secint == 3){
	M = adjectives;
		for (count=0; count < adjectives; count++){
		memcpy(atype, aadjectives, sizeof(char *) * 50);
		memcpy(qtype, qadjectives, sizeof(char *) * 50);
		}}
	if (secint == 4){
	M = articles;
		for (count=0; count < articles; count++){
		memcpy(atype, aarticles, sizeof(char *) * 50);
		memcpy(qtype, qarticles, sizeof(char *) * 50);
		}}
	if (secint == 5){
	M = adverbs;
		for (count=0; count < adverbs; count++){
		memcpy(atype, aadverbs, sizeof(char *) * 50);
		memcpy(qtype, qadverbs, sizeof(char *) * 50);
		}}
	if (secint == 6){
	M = pronouns;
		for (count=0; count < pronouns; count++){
		memcpy(atype, apronouns, sizeof(char *) * 50);
		memcpy(qtype, qpronouns, sizeof(char *) * 50);
		}}
	if (secint == 7){
	M = phrases;
		for (count=0; count < phrases; count++){
		memcpy(atype, aphrases, sizeof(char *) * 50);
		memcpy(qtype, qphrases, sizeof(char *) * 50);
		}}
	if (secint == 8){
	M = conjunctions;
		for (count=0; count < conjunctions; count++){
		memcpy(atype, aconjunctions, sizeof(char *) * 50);
		memcpy(qtype, qconjunctions, sizeof(char *) * 50);
		}}
	if (secint == 9){
	M = prepositions;
		for (count=0; count < prepositions; count++){
		memcpy(atype, aprepositions, sizeof(char *) * 50);
		memcpy(qtype, qprepositions, sizeof(char *) * 50);
		}}
	if (secint == 0){
	endwin();
	return 0;
	exit(0);
	}

	int order[M];
	werase(stdscr);
	
for (count=0; count<M; count++){
	order[count] = count;
	}
for (count=0; M > count; ++count) {
	ra = rand() % (count + 1);
	order[count] = 0;
	order[count] = order[ra];
	order[ra] = count;
	}
if (argc > 1){
	loopnum = strtol(argv[1],NULL,0);
	}
if (loopnum > M){
	loopnum = M;
	}

for(count=0; count<loopnum; ++count)
	{
	wborder(stdscr, 0, 0, 0, 0, 0, 0, 0, 0);
	y = order[count];
	bannerf();
   attron(COLOR_PAIR(1));
	mvprintw((row/2)+2,alignint,"Question #%d (%i of %i)",y,count+1,loopnum);
	mvprintw((row/2)+3,alignint,"------------------------",NULL);
   attroff(COLOR_PAIR(1));
	mvprintw((row/2)+4,alignint,"Translate: %s",qtype[y]);
	mvprintw((row/2)+5,alignint,"Answer: ");
	refresh();
	getstr(ans);
			if (!strcmp(ans, atype[y])){
		   attron(COLOR_PAIR(2));
			mvprintw((row/2)+7,alignint,"Correct!",NULL);
		   attroff(COLOR_PAIR(2));
			refresh();
			getch();
			werase(stdscr);
			right++;
			} else {
		   attron(COLOR_PAIR(3));
			mvprintw((row/2)+7,alignint,"Incorrect! ",NULL);
		   attroff(COLOR_PAIR(3));
			mvprintw((row/2)+7,alignint+11,"Answer: %s",atype[y]);
			refresh();
			getch();
			werase(stdscr);
			wrong++;
			}
   	}
		
 werase(stdscr);
 wborder(stdscr, 0, 0, 0, 0, 0, 0, 0, 0);
 bannerf();
 attron(COLOR_PAIR(1));	
 mvprintw((row/2)+2,(col-strlen("Results"))/2,"Results");
 mvprintw((row/2)+3,(col-strlen("------------------------"))/2,"------------------------",NULL);
 attroff(COLOR_PAIR(1));
 attron(COLOR_PAIR(2));
 mvprintw((row/2)+4,alignint,"%d Correct Answers",right);
 attroff(COLOR_PAIR(2));
 attron(COLOR_PAIR(3));
 mvprintw((row/2)+5,alignint,"%d Incorrect Answers\n",wrong);
 attron(COLOR_PAIR(3));
 
 refresh();
 getch(); 
 endwin();
 main(0,0);
 return 0;

}