lonsomehell

extraction

May 4th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.92 KB | None | 0 0
  1. program extraction;
  2. uses wincrt;
  3. var
  4. ch:string;
  5. n,m:integer;
  6. ex:boolean;
  7. function ext1(c:string):integer;
  8. var
  9. c1:string;
  10. e,i,l:integer;
  11. begin
  12. c1:='';
  13. for i:=1 to length (c) do
  14. begin
  15. if c[i] in ['0'..'9'] then c1:=(c1+c[i]);
  16. end;
  17. Val(c1,l,e);
  18. ext1:=l;
  19. end;
  20. procedure ext2(c:string;var k:integer);
  21. var
  22. i,e:integer;
  23. c1:string;
  24. begin
  25. c1:='';
  26. for i:=length(c) downto 1 do
  27. begin
  28. if c[i] in ['0'..'9'] then c1:=(c1+c[i]);
  29. end;
  30. val(c1,k,e);
  31. end;
  32. function cont(c:string):boolean;
  33. var
  34. i:integer;
  35. existe:boolean;
  36. begin
  37. existe:=false;
  38. for i:= 1 to length(c) do
  39. begin
  40. if (c[i] in ['0'..'9']) then existe:=true;
  41. end;
  42. cont:=existe;
  43. end;
  44. begin
  45. writeln('entrer la chaine');
  46. readln(ch);
  47. ex:=cont(ch);
  48. if (ex=false) then writeln('il n"y a aucun nombre')
  49. else
  50. begin
  51. n:=ext1(ch);
  52. ext2(ch,m);
  53. writeln('le premier nbre est ',n,' le deuxième nbre est ',m);
  54. end;
  55. writeln('Press <Enter> To Quit');
  56.   readln();
  57. end.
Advertisement
Add Comment
Please, Sign In to add comment