Académique Documents
Professionnel Documents
Culture Documents
While(not isempty(q))
Data= Dequeue(q)
Push(stk,data)
End while
While(not isempty(stk))
Data = Pop(stk)
Enqueue(q,data)
End while
#include <stdio.h>
Int main(){
Int target,num[20],I;
Printf(Please enter the target which you would like to search for)
Scanf(%d,&target);
For(i=0;i<20;i++){
If(num[i]==target){
Printf(The target %d is found at position %d,target,i);
Break;
}
}
If(x==20){
Printf(The target is not in the list);
}
}
CAPE 2011
#include <stdio.h>
Void main(){
Int arr[]={3,12,9,10,5,4};
Int temp,smallval,smallpos,x,y;
For (x=0;x<=4,x++){
Smallval= arr[x];
Smallpos=x;
}
For(y=x+1;y<=4;y++){
If( arr[y]<smallval){
Smallpos=y;}
Smallval=arr[y]
}
Temp=arr[x];
Arr[x]=smallVal;
Arr[SmallPos]=temp;
}
Return 0;
}
CAPE 2012
Int top=-1;
Int stk[100];
#include <stdio.h>
void main(){
Int marks[100],lower,upper,count=0,i;
Printf(Please enter the lower and upper boundaries);
Scanf(%d%d,&lower,&upper);
For (i=0;i<100;i++){
If(marks[i]>=lower && marks[i] <= upper)
Count = count +1;
}
If (count>0){
Printf(There are %d values in this range,count);
} else
Printf(There are no marks in the range);
}
CAPE 2013
Int stk[1000];
Int top=-1;
char pop(){
char element = ;
If(top==-1){
Printf(Stack undeflow);
} else
Element=stk[top];
Top--;
Return element;
}
CAPE 2014
Count=0
While(not isempty(q))
Dequeue(q,element)
Count= Count+1
End While
Return count
Int num[100];
Int I;
For(i=0;i<100;i++){
Scanf(%d,val)
Num[i]=val;
}