def main
(args
: Array
[String
]) { val l
= List
(new AClass, AnObject, ACompanionExample
) l.map(a => a.autocorrect)
.foreach(println)
}
}
def autocorrect
: String
// this is abstract }
def autocorrect
= "AClass autocorrect" }
def autocorrect
= "AnObject autocorrect" }
def autocorrect
= "CompanionExample autocorrect" }
Cm9iamVjdCBNYWluIHsKICBkZWYgbWFpbihhcmdzOiBBcnJheVtTdHJpbmddKSB7CiAgICAgIHZhbCBsID0gTGlzdChuZXcgQUNsYXNzLCBBbk9iamVjdCwgQUNvbXBhbmlvbkV4YW1wbGUpCiAgICAgIGwubWFwKGEgPT4gYS5hdXRvY29ycmVjdCkKICAgICAgLmZvcmVhY2gocHJpbnRsbikKICB9Cgp9Cgp0cmFpdCBBdXRvY29ycmVjdG9yIHsKICBkZWYgYXV0b2NvcnJlY3Q6IFN0cmluZyAvLyB0aGlzIGlzIGFic3RyYWN0Cn0KCmNsYXNzIEFDbGFzcyBleHRlbmRzIEF1dG9jb3JyZWN0b3IgewogIGRlZiBhdXRvY29ycmVjdCA9ICJBQ2xhc3MgYXV0b2NvcnJlY3QiCn0KCm9iamVjdCBBbk9iamVjdCBleHRlbmRzIEF1dG9jb3JyZWN0b3IgewogIGRlZiBhdXRvY29ycmVjdCA9ICJBbk9iamVjdCBhdXRvY29ycmVjdCIKfQoKY2xhc3MgQUNvbXBhbmlvbkV4YW1wbGUKb2JqZWN0IEFDb21wYW5pb25FeGFtcGxlIGV4dGVuZHMgQXV0b2NvcnJlY3RvciB7CiAgZGVmIGF1dG9jb3JyZWN0ID0gIkNvbXBhbmlvbkV4YW1wbGUgYXV0b2NvcnJlY3QiCn0K
CiNpbmNsdWRlJmx0O3N0ZGlvLmgmZ3Q7CgojaW5jbHVkZSZsdDtzdGRsaWIuaCZndDsKCiNkZWZpbmUgTUFYIDUKCmludCB0b3A9LTEsc3RhY2tbTUFYXTsKIHZvaWQgcHVzaCgpOwogIHZvaWQgcG9wKCk7CiAgdm9pZCBkaXNwbGF5KCk7CiAgCiAgC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KCXRvcD10b3AtMTsKCQp9IAp9CnZvaWQgZGlzcGxheSgpCnsKCWludCBpOwoJaWYgKHRvcD09LTEpCnsKCQlwcmludGYoJnF1b3Q7XG5zdGFjayBpcyBlbXB0eSEhJnF1b3Q7KTsKCX0KCWVsc2UKCXsKCQlwcmludGYoJnF1b3Q7XG5zdGFjayBpcy4uLlxuJnF1b3Q7KTsKCQlmb3IoaT10b3A7aSZndDs9MDstLTEpCgkJcHJpbnRmKCZxdW90OyVkXG4mcXVvdDssc3RhY2tbaV0pOwoJfQoJIH0gCgkKCQkK
#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]);
}
}