fork download
  1.  
  2. object Main {
  3. def main(args: Array[String]) {
  4. val l = List(new AClass, AnObject, ACompanionExample)
  5. l.map(a => a.autocorrect)
  6. .foreach(println)
  7. }
  8.  
  9. }
  10.  
  11. trait Autocorrector {
  12. def autocorrect: String // this is abstract
  13. }
  14.  
  15. class AClass extends Autocorrector {
  16. def autocorrect = "AClass autocorrect"
  17. }
  18.  
  19. object AnObject extends Autocorrector {
  20. def autocorrect = "AnObject autocorrect"
  21. }
  22.  
  23. class ACompanionExample
  24. object ACompanionExample extends Autocorrector {
  25. def autocorrect = "CompanionExample autocorrect"
  26. }
  27.  
Success #stdin #stdout 0.63s 54472KB
stdin
#include<stdio.h>

#include<stdlib.h>

#define MAX 5

int top=-1,stack[MAX];
 void push();
  void pop();
  void display();
  
  
  int main()
  {
  	int ch;
  	while(1)
  	{
  		printf("\n**stack menu**");
  		printf("\n\n1.push\n2.pop\n3.display\n4.exit");
  		printf("\n\nenter your choice(1-4):");
  		scanf("%d",&ch);
  		switch(ch)
	  
	  {
	  	case 1:push()
	  	break;
	  	
	  		  	case 2:pop()
	  	break;
	  	
	  		  	case 3:display()
	  	break;
	  	
	  		  	case 4:exit(0);
	  	deafult:printf("\nwrong choice!!");
	  }
  }
}
void push()
{
	int val;
	if(top==MAX-1)
{
printf("\nstack is full!!");

}


else

{
	
	printf("\nenter elemrnt to push:");
	scanf("%d",&val);
	top=top+1;
	stack[top]=val;
}


}

void pop()
{
if(top==-1)
{
	printf("\nstack is empty!!");
}
else 

{
	printf("\ndeleted element is %d",stack[top]);
	top=top-1;
	
} 
}
void display()
{
	int i;
	if (top==-1)
{
		printf("\nstack is empty!!");
	}
	else
	{
		printf("\nstack is...\n");
		for(i=top;i>=0;--1)
		printf("%d\n",stack[i]);
	}
	 } 
	
		
stdout
AClass autocorrect
AnObject autocorrect
CompanionExample autocorrect