A
A
Anvario02022-01-13 19:23:55
C++ / C#
Anvario0, 2022-01-13 19:23:55

Why is the C program silent?

task:
Find sequences of digits in the string, consider each of them as a number in the number system that corresponds to the maximum digit, replace the numbers in the string with symbols with codes obtained from these numbers. Example: aaa010101bbb343ccc - binary and five-digit number systems.
the code:

#include <stdio.h>
#include <math.h>

int funcc(char a[]) {
  int length = strlen(a);
  printf("length = %d\n", length);
  char num[255];
  int w;
  int check = 0;
  for (int i = 0; i < length; i++)
  {
    w = atoi(num);
    if (a[i] == '0') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '1') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '2') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '3') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '4') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '5') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '6') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '7') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '8') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    if (a[i] == '9') {
      num[i] = a[i];
      continue;
      check = 1;
    }
    else {
      int secondw;
      secondw = w;
      if (check == 1) {
        printf("w = %d\n", w);
        int a = 0;
        while (w > 0) {
          int b = w % 10;
          if (b > a) {
            a = b;
          }
          w /= 10;
        }
        a++;
        printf("sistema schisleniya = %d\n", a);
        int ssm = 0;
        int u = 0;
        while (secondw > 0) {
          ssm += secondw % 10 * pow(a, u);
          secondw /= 10;
          u++;
        }
        printf("perevod = %d\n\n", ssm);
        check = 0;
      }
      continue;
    }
  }
}

int main()
{
  char mas[19] = "010101bbb343ccc";
  funcc(mas);
}

but the program only returns the length of the array. Why?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question