我已经通过链表给出了输入AMAZON。输出应该是AAOMZN。ie前面的元音和后面的辅音。Netbeans IDE没有显示任何输出。如果有错误请指出错误。为什么IDE没有显示任何输出。我的代码:
class Node
{
char value;
Node next;
}
public class AmazonProb1
{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
String str=s.nextLine();
StringTokenizer ss=new StringTokenizer(str);
Node a1=new Node();
Node a2=new Node();
Node a3=new Node();
Node a4=new Node();
Node a5=new Node();
Node a6=new Node();
a1.value='A';
a2.value='M';
a3.value='A';
a4.value='Z';
a5.value='O';
a6.value='N';
a1.next=a2;
a2.next=a3;
a3.next=a4;
a4.next=a5;
a5.next=a6;
a6.next=null;
Node x=new Node();
Node head=new Node();
head=a1;
x=a1;
for(int i=0;i<6;i++)
{
if(head.value==(('A')|('O')|('E')|('I')|('U')))
{
head=head.next;
}
else if(head.value!=(('A')|('O')|('E')|('I')|('U')))
{
x=head;
while(head.value!=(('A')|('O')|('E')|('I')|('U')))
{
x=x.next;
}
swap(x,head);
}
}
System.out.println(a1);
System.out.println(a2);
System.out.println(a3);
System.out.println(a4);
System.out.println(a5);
System.out.println(a6);
}
public static void swap(Node a,Node b)
{
Node temp=new Node();
temp=a;
a=b;
b=temp;
}
}