Advertisement
erfanul007

UVa 10474

Nov 24th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,m,c,cnt=0;
  5. while(1){
  6. cnt++;
  7. scanf("%d %d",&n,&m);
  8. if(n==0 && m==0)
  9. break;
  10. int i,j,a[10000],temp;
  11. for(i=1;i<=n;i++){
  12. scanf("%d",&a[i]);
  13. }
  14. for(i=1;i<=n;i++){
  15. for(j=i+1;j<=n;j++){
  16. if(a[i]>a[j]){
  17. temp=a[i];
  18. a[i]=a[j];
  19. a[j]=temp;
  20. }
  21. }
  22. }
  23. int t,max;
  24. printf("CASE# %d:\n",cnt);
  25. for(i=1;i<=m;i++){
  26. max=0;
  27. scanf("%d",&t);
  28. for(j=1;j<=n;j++){
  29. if(a[j]==t){
  30. printf("%d found at %d\n",t,j);
  31. max++;
  32. break;
  33. }
  34. }
  35. if(max==0)
  36. printf("%d not found\n",t);
  37.  
  38. }
  39. }
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement