Advertisement
rotti321

ADM UBB2018

Nov 16th, 2021
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1.  
  2. //B1 UBB2018
  3. #include <iostream>
  4.  
  5. using namespace std;
  6. int conversie(char s[],int lung){
  7. if(lung==1){
  8. if(s[lung]>='A')
  9. return s[lung] - 'A' + 10;
  10. else
  11. return s[lung] - '0';
  12. }
  13. else{
  14. if(s[lung]>='A')
  15. return conversie(s,lung-1)*16+s[lung] - 'A' + 10;
  16. else
  17. return conversie(s,lung-1)*16+s[lung] - '0';
  18. }
  19. }
  20. int main() {
  21. char s[100];
  22. int lung=2;
  23. cin >>(s+1);
  24. cout<<conversie(s,lung);
  25. return 0;
  26. }
  27. ///b2 ubb 2018
  28.  
  29. #include <iostream>
  30.  
  31. using namespace std;
  32.  
  33. void f(int a, int b, int x[], int &k) {
  34. int p = 1;
  35. k = 0;
  36. while(p * 10 + 1 <= a) {
  37. p = p * 10 + 1;
  38. }
  39. while(p <= b) {
  40. for(int c = 1; c <= 9; c++) {
  41. if(c * p >= a && c * p <= b) {
  42. k++;
  43. ///x[k] = c * p;
  44. cout << x[k] << ' ';
  45. }
  46. }
  47. p = p * 10 + 1;
  48. }
  49. ///cout << endl;
  50. }
  51.  
  52. int main() {
  53. int a, b, x[1001] = {}, k;
  54. cin >> a >> b;
  55. f(a, b, x, k);
  56. for(int i = 1; i <= k; i++) {
  57. cout << x[i] << ' ';
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement