1. Python / Говнокод #28879

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    # Теперь нам нужны несколько изображений для выполнения
    # логического вывода. Давайте загрузим их с помощью wget.
    
    urls = [
        "https://mir-s3-cdn-cf.behance.net/project_modules/max_3840/2712bd29493563.55f6ec5e98924.jpg",
        "https://i.pinimg.com/736x/5a/8a/5c/5a8a5c4cd658580ae4719e5c96043541.jpg",
        "https://mir-s3-cdn-cf.behance.net/project_modules/max_1200/4d222729493563.55f6420cd3768.jpg"
    ]
    downloaded_files = []
     
    for index, url in enumerate(urls, start=1):
      os.system(f"wget {url} -O pose-{index}.jpg")
      downloaded_files.append(f"pose-{index}.jpg")

    Датасаентист — не программист, и сегодня ему предстояла трудная ночь...

    https://habr.com/ru/articles/772558/

    ISO, 08 Ноября 2023

    Комментарии (15)
  2. Куча / Говнокод #28878

    0

    1. 1
    IT Оффтоп #191

    #161: (vanished) https://govnokod.xyz/_28449
    #162: https://govnokod.ru/28477 https://govnokod.xyz/_28477
    #163: https://govnokod.ru/28501 https://govnokod.xyz/_28501
    #164: https://govnokod.ru/28527 https://govnokod.xyz/_28527
    #165: https://govnokod.ru/28557 https://govnokod.xyz/_28557
    #166: https://govnokod.ru/28574 https://govnokod.xyz/_28574
    #167: https://govnokod.ru/28588 https://govnokod.xyz/_28588
    #168: https://govnokod.ru/28607 https://govnokod.xyz/_28607
    #169: https://govnokod.ru/28628 https://govnokod.xyz/_28628
    #170: https://govnokod.ru/28653 https://govnokod.xyz/_28653
    #171: (vanished) https://govnokod.xyz/_28665
    #172: https://govnokod.ru/28675 https://govnokod.xyz/_28675
    #173: https://govnokod.ru/28681 https://govnokod.xyz/_28681
    #174: https://govnokod.ru/28689 https://govnokod.xyz/_28689
    #175: https://govnokod.ru/28696 https://govnokod.xyz/_28696
    #176: https://govnokod.ru/28703 https://govnokod.xyz/_28703
    #177: https://govnokod.ru/28709 https://govnokod.xyz/_28709
    #178: https://govnokod.ru/28716 https://govnokod.xyz/_28716
    #179: https://govnokod.ru/28726 https://govnokod.xyz/_28726
    #180: https://govnokod.ru/28734 https://govnokod.xyz/_28734
    #181: https://govnokod.ru/28739 https://govnokod.xyz/_28739
    #182: https://govnokod.ru/28749 https://govnokod.xyz/_28749
    #183: https://govnokod.ru/28777 https://govnokod.xyz/_28777
    #184: https://govnokod.ru/28790 https://govnokod.xyz/_28790
    #185: https://govnokod.ru/28794 https://govnokod.xyz/_28794
    #186: https://govnokod.ru/28815 https://govnokod.xyz/_28815
    #187: https://govnokod.ru/28833 https://govnokod.xyz/_28833
    #188: https://govnokod.ru/28837 https://govnokod.xyz/_28837
    #189: https://govnokod.ru/28840 https://govnokod.xyz/_28840
    #190: https://govnokod.ru/28875 https://govnokod.xyz/_28875

    nepeKamHblu_nemyx, 04 Ноября 2023

    Комментарии (149)
  3. C# / Говнокод #28877

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    string[] words = line.Split(' ');
    foreach (var word in words)
    {
        Console.Write(word);
        switch (word)
        {
            case "11":
                Console.WriteLine($"{tableEng[0, 0]}");
                break;
            case "12":
                Console.WriteLine($"{tableEng[0, 1]}");
                break;
            case "13":
                Console.WriteLine($"{tableEng[0, 2]}");
                break;
            case "14":
                Console.WriteLine($"{tableEng[0, 3]}");
                break;
            case "15":
                Console.WriteLine($"{tableEng[0, 4]}");
                break;
            case "21":
                Console.WriteLine($"{tableEng[1, 0]}");//
                break;
            case "22":
                Console.WriteLine($"{tableEng[1, 1]}");
                break;
            case "23":
                Console.WriteLine($"{tableEng[1, 2]}");
                break;
            case "24":
                Console.WriteLine($"{tableEng[1, 3]}");
                break;
            case "25":
                Console.WriteLine($"{tableEng[1, 4]}");
                break;
            case "31":
                Console.WriteLine($"{tableEng[2, 0]}");
                break;
            case "32":
                Console.WriteLine($"{tableEng[2, 1]}");
                break;
            case "33":
                Console.WriteLine($"{tableEng[2, 2]}");
                break;
            case "34":
                Console.WriteLine($"{tableEng[2, 3]}");
                break;
            case "35":
                Console.WriteLine($"{tableEng[2, 4]}");
                break;
            case "41":
                Console.WriteLine($"{tableEng[3, 0]}");
                break;
            case "42":
                Console.WriteLine($"{tableEng[3, 1]}");
                break;
            case "43":
                Console.WriteLine($"{tableEng[3, 2]}");
                break;
            case "44":
                Console.WriteLine($"{tableEng[3, 3]}");
                break;
            case "45":
                Console.WriteLine($"{tableEng[3, 4]}");
                break;
            case "51":
                Console.WriteLine($"{tableEng[4, 0]}");
                break;
            case "52":
                Console.WriteLine($"{tableEng[4, 1]}");
                break;
            case "53":
                Console.WriteLine($"{tableEng[4, 2]}");
                break;
            case "54":
                Console.WriteLine($"{tableEng[4, 3]}");
                break;
            case "55":
                Console.WriteLine($"{tableEng[4, 4]}");
                break;
        }
        
    }
    }
    Console.ReadLine();

    Дело IsBukva живёт.

    https://habr.com/ru/articles/771530/

    ISO, 03 Ноября 2023

    Комментарии (34)
  4. Python / Говнокод #28876

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    n = int(input())
    m = int(input())
    if m > 1:
        chast1 = n * 2
        vsegoch = chast1 * (m + 1) 
        print(vsegoch)
    else:
        print(n * 2)

    bobrrrrrr00mailru, 27 Октября 2023

    Комментарии (5)
  5. Куча / Говнокод #28875

    0

    1. 1
    IT Оффтоп #190

    #160: https://govnokod.ru/28434 https://govnokod.xyz/_28434
    #161: (vanished) https://govnokod.xyz/_28449
    #162: https://govnokod.ru/28477 https://govnokod.xyz/_28477
    #163: https://govnokod.ru/28501 https://govnokod.xyz/_28501
    #164: https://govnokod.ru/28527 https://govnokod.xyz/_28527
    #165: https://govnokod.ru/28557 https://govnokod.xyz/_28557
    #166: https://govnokod.ru/28574 https://govnokod.xyz/_28574
    #167: https://govnokod.ru/28588 https://govnokod.xyz/_28588
    #168: https://govnokod.ru/28607 https://govnokod.xyz/_28607
    #169: https://govnokod.ru/28628 https://govnokod.xyz/_28628
    #170: https://govnokod.ru/28653 https://govnokod.xyz/_28653
    #171: (vanished) https://govnokod.xyz/_28665
    #172: https://govnokod.ru/28675 https://govnokod.xyz/_28675
    #173: https://govnokod.ru/28681 https://govnokod.xyz/_28681
    #174: https://govnokod.ru/28689 https://govnokod.xyz/_28689
    #175: https://govnokod.ru/28696 https://govnokod.xyz/_28696
    #176: https://govnokod.ru/28703 https://govnokod.xyz/_28703
    #177: https://govnokod.ru/28709 https://govnokod.xyz/_28709
    #178: https://govnokod.ru/28716 https://govnokod.xyz/_28716
    #179: https://govnokod.ru/28726 https://govnokod.xyz/_28726
    #180: https://govnokod.ru/28734 https://govnokod.xyz/_28734
    #181: https://govnokod.ru/28739 https://govnokod.xyz/_28739
    #182: https://govnokod.ru/28749 https://govnokod.xyz/_28749
    #183: https://govnokod.ru/28777 https://govnokod.xyz/_28777
    #184: https://govnokod.ru/28790 https://govnokod.xyz/_28790
    #185: https://govnokod.ru/28794 https://govnokod.xyz/_28794
    #186: https://govnokod.ru/28815 https://govnokod.xyz/_28815
    #187: https://govnokod.ru/28833 https://govnokod.xyz/_28833
    #188: https://govnokod.ru/28837 https://govnokod.xyz/_28837
    #189: https://govnokod.ru/28840 https://govnokod.xyz/_28840

    nepeKamHblu_nemyx, 17 Октября 2023

    Комментарии (474)
  6. Куча / Говнокод #28874

    0

    1. 1
    Пиздец-оффтоп #90

    #60: https://govnokod.ru/28540 https://govnokod.xyz/_28540
    #61: https://govnokod.ru/28548 https://govnokod.xyz/_28548
    #62: https://govnokod.ru/28555 https://govnokod.xyz/_28555
    #63: https://govnokod.ru/28573 https://govnokod.xyz/_28573
    #64: https://govnokod.ru/28584 https://govnokod.xyz/_28584
    #65: https://govnokod.ru/28599 https://govnokod.xyz/_28599
    #66: https://govnokod.ru/28609 https://govnokod.xyz/_28609
    #67: (vanished) https://govnokod.xyz/_28615
    #68: https://govnokod.ru/28636 https://govnokod.xyz/_28636
    #69: (vanished) https://govnokod.xyz/_28660
    #70: (vanished) https://govnokod.xyz/_28667
    #71: https://govnokod.ru/28677 https://govnokod.xyz/_28677
    #72: https://govnokod.ru/28685 https://govnokod.xyz/_28685
    #73: https://govnokod.ru/28692 https://govnokod.xyz/_28692
    #74: https://govnokod.ru/28699 https://govnokod.xyz/_28699
    #75: https://govnokod.ru/28705 https://govnokod.xyz/_28705
    #76: https://govnokod.ru/28712 https://govnokod.xyz/_28712
    #77: https://govnokod.ru/28722 https://govnokod.xyz/_28722
    #78: https://govnokod.ru/28730 https://govnokod.xyz/_28730
    #79: https://govnokod.ru/28736 https://govnokod.xyz/_28736
    #80: https://govnokod.ru/28740 https://govnokod.xyz/_28740
    #81: https://govnokod.ru/28750 https://govnokod.xyz/_28750
    #82: https://govnokod.ru/28779 https://govnokod.xyz/_28779
    #83: https://govnokod.ru/28788 https://govnokod.xyz/_28788
    #84: https://govnokod.ru/28795 https://govnokod.xyz/_28795
    #85: https://govnokod.ru/28808 https://govnokod.xyz/_28808
    #86: (vanished) https://govnokod.xyz/_28814
    #87: https://govnokod.ru/28817 https://govnokod.xyz/_28817
    #88: https://govnokod.ru/28836 https://govnokod.xyz/_28836
    #89: https://govnokod.ru/28843 https://govnokod.xyz/_28843

    nepeKamHblu_nemyx, 15 Октября 2023

    Комментарии (373)
  7. PHP / Говнокод #28873

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <?php
    
    namespace App\Http\Controllers\api\v1;
    
    use App\Http\Controllers\Controller;
    use App\Http\Requests\StandartRequest;
    use App\Models\Attractions;
    use App\Models\AttractionSessionUpdates;
    use App\Models\Locations;
    use App\Models\SessionAttractionHistory;
    use App\Models\SessionsHistoryAttractions;
    use App\Models\SessionsHistoryGames;
    use App\Models\Statistic\CountEndAttractionSessions;
    use Illuminate\Http\Request;
    use Illuminate\Support\Carbon;
    use Illuminate\Support\Facades\Auth;
    use Illuminate\Support\Facades\Cache;
    use Illuminate\Support\Facades\Log;
    
    class AttractionEndSessionsCount extends Controller
    {
        public function endSessions(StandartRequest $request){
            $this->now_time = Carbon::now();
    
            $locations = Locations::where('user_id', '=', Auth::user()->id)->get();
            if (count($locations) == 0){
                return response()->json(['code' => "404", 'status' => 'error' , 'message'=> "locations not found"]);
            }
            try {
                $request_from = $request->input('date_from');
                $from = Carbon::parse($request_from."00:00:01");
    
                $date_to = $request->input('date_to');
                $to = Carbon::parse($date_to."11:59:59");
            } catch (\Exception $exception){
                return response()->json(['code' => "422", 'status' => 'error' , 'message'=> "dates have bad format, failed parse"]);
            }
    
            if ($from->timestamp > $to->timestamp){
                return response()->json(['code' => "422", 'status' => 'error' , 'message'=> "the start date is larger than the end date"]);
            }
    
            $is_detail = $request->input('detail', 'daily');
    
            $arr = $this->prepareLocationsAndAttrctions($locations, $from, $to, $is_detail);
    
            $locations_ids = [];
            foreach ($locations as $loc){
                $locations_ids[] = $loc->id;
            }
    
            $history = CountEndAttractionSessions::query()->whereIn('location_id', array_values($locations_ids))
                ->whereBetween('day_date', [$from->startOfDay()->format('Y-m-d H:i:s'), $to->endOfDay()->format('Y-m-d H:i:s')])
                ->get();
    
            $resp = $this->fillResults($arr ,$history, $is_detail);
            if ($this->is_today){
                $resp = $this->fillTodayResult($resp, $locations_ids, $is_detail);
            }
            return response()->json(['code' => "200", 'status' => 'success' , 'data'=> $resp]);
    
        }
    
        private function fillResults($arr ,$history, $is_detail){
            foreach ($history as $value){
                try {
                    if ($is_detail == 'hourly'){
                        $arr['locations'][$value->location_id]['attractions'][$value->attraction_id]['list'][$value->day_date->format('d-m-Y')][$value->day_date->format('H:00:00')] =
                            [
                                // общее количество игр
                                'total_count' => $value->total_count ?? 0,
                                //общее количество обновлений
                                'total_updates_count' => $value->total_updates_count ?? 0,
                                // количество пролонгейт обновлений
                                'add_time' => $value->add_time ?? 0,
                                // количество лет_гейм обновлений
                                'let_game_end' => $value->let_game_end ?? 0,
                                //средняя длина игры в секундах
                                'avg_duration' => [
                                    'sum_seconds' => $value->avg_duration_second_sum,
                                    'count_games' => $value->avg_duration_count_games,
                                ],
                                // минимальная игра в секундах
                                'min_duration' => $value->min_duration,
                                // максимальная игра в секундах
                                'max_duration' => $value->max_duration,
                    ];
                        for ($i = 1; $i <= 10; $i++){
                            $selector = 'max_players_'.$i;
                            $arr['locations'][$value->location_id]
                            ['attractions'][$value->attraction_id]
                            ['list'][$value->day_date->format('d-m-Y')]
                            [$value->day_date->format('H:00:00')]
                            ['max_players'][$i] = (int)$value->$selector;
                        }
                    }elseif ($is_detail == 'daily') {
                        $arr['locations'][$value->location_id]['attractions'][$value->attraction_id]
                        ['list'][$value->day_date->format('d-m-Y')]['total_count'] += $value->total_count;
    
                        $arr['locations'][$value->location_id]['attractions'][$value->attraction_id]

    расчет заранее посчитанной оффлайн и онлайн статистики

    tlen, 06 Октября 2023

    Комментарии (1)
  8. Си / Говнокод #28872

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    void branch(int *cnt, int accum, int nxt, int comn) {
      printf("accum %d %d\n", accum, comn);
      if (accum < 0 && comn == 41) {
        *cnt = nxt;
      } else if (accum == 0 && comn == 42) {
        *cnt = nxt;
      } else if (comn == 40) {
        *cnt = nxt;
      }
    
      else {
        (*cnt)++;
      }
    }
    
    
    void dump(int word[]) {
      int d = 0, x;
      printf("%3c", ' ');
      while (d != 10) {
        printf("%5d ", d);
        d++;
      }
      for (d = 0; d != MEM; d++) {
        x = word[d];
        if (0 == (d % 10))
          puts(" "), printf("%3d", d);
        printf(x >= 0 ? " +%.4X" : " %.4d", x);
      }
      puts(" ");
    }
    
    void dump_file(int word[]) {
      int d = 0, x;
      FILE *flrun;
      flrun = fopen("wrt.txt", "w+");
    
      fprintf(flrun, "%3c", ' ');
      while (d != 10) {
        fprintf(flrun, "%5d ", d);
        d++;
      }
      for (d = 0; d != MEM; d++) {
        x = word[d];
        if (0 == (d % 10))
          fprintf(flrun, "\n"), fprintf(flrun, "%3d", d);
        fprintf(flrun, x >= 0 ? " +%.4X" : " %.4d", x);
      }
    }
    
    long long_var(long var) {
      long step = 1;
      do {
        step *= 10;
      } while (var /= step);
      return (step / 10);
    }

    Демотрон 3
    Читалка для кода симплтрона

    gne4do, 02 Октября 2023

    Комментарии (4)
  9. Си / Говнокод #28871

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    fclose(cfPtr);
    
      while ((mem[operand] > -9999) && (mem[operand] < 9999) && sign != 1) {
    
        ins_rgr = (mem[ins_cnt]);
    
        op_code = (ins_rgr / 100);
        operand = (ins_rgr % 100);
        // printf("op_code = %d   operand = %d  acc = %d\n", op_code, operand , acc
        // );
        //    dump(mem);
    
        switch (op_code) {
    
        case HALT:
          sign = 1;
          break;
    
        case READ:
          printf("? read ");
    
          scanf("%d", &buf);
          mem[operand] = buf;
    
          ins_cnt++;
          break;
    
        case WRITE:
          printf("%d\n", mem[operand]);
          ins_cnt++;
          break;
    
        case LOAD:
    
          acc = mem[operand];
          ins_cnt++;
          break;
    
        case STORE:
    
          mem[operand] = acc;
          ins_cnt++;
          break;
    
        case ADD:
    
          acc += mem[operand];
          ins_cnt++;
          break;
    
        case SUBSTRACT:
    
          acc -= mem[operand];
          ins_cnt++;
    
          break;
    
        case DIVIDE:
    
          acc /= mem[operand];
          ins_cnt++;
          break;
    
        case MUL:
    
          acc *= mem[operand];
          ins_cnt++;
          break;
    
        case POW:
          acc = pow(acc, mem[operand]);
          ins_cnt++;
          break;
    
        case MOD:
          acc = fmod(acc, mem[operand]);
          ins_cnt++;
          break;
    
        case NEWLINE:
          puts(" ");
          ins_cnt++;
          break;
    
        case BRANCH:
        case BRANCHZERO:
        case BRANCHNEG:
       
          branch(&ins_cnt, acc, operand, op_code);
    
          break;
    
         
        }
      }
    
      dump(mem);
      dump_file(mem);
      puts(" ");
    }

    Демотрон 2
    Читалка для кода симплтрона

    gne4do, 02 Октября 2023

    Комментарии (8)
  10. Си / Говнокод #28870

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    #include <ctype.h>
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #define MEM 100
    #define READ 10
    #define WRITE 11
    #define LOAD 20
    #define STORE 21
    #define NEWLINE 22
    #define ADD 30
    #define SUBSTRACT 31
    #define DIVIDE 32
    #define MUL 33
    
    #define POW 34
    #define MOD 35
    
    #define ENTSTR 50
    
    #define PRTSTR 51
    
    #define BRANCH 40
    #define BRANCHNEG 41
    #define BRANCHZERO 42
    #define HALT 43
    int main(int argc, char *argv[]) {
      void dump_file(int word[]);
    
      FILE *cfPtr;
    
      // char buf[5];
      void branch(int *cnt, int accum, int nxt, int comn);
      int buf_mem[100] = {0};
      void dump(int word[]);
      int x = 0, y = 0, s = 0;
      // int mem[MEM] = {0};
      int mem[MEM];
    
      for (; x != MEM; x++) {
        mem[x] = 0;
      }
    
      int acc = 0, d = 0;
      int ins_cnt = 0, ins_rgr = 0, op_code = 0, operand = 0, buf = 0;
    
      int b = 0, l, r = 0, m = 0, ti = 0, sign = 0;
    
      cfPtr = fopen(argv[1], "r");
    
      for (; feof(cfPtr) == 0;) {
        fscanf(cfPtr, "%d %d\n", &b, &l);
        mem[b] = l;
      
      }

    Демотрон 1
    Читалка для кода симплтрона

    gne4do, 02 Октября 2023

    Комментарии (0)