[Logo] Форум DL
  [DL]  На главную страницу 
Индекс форума ->Учебный процесс ГГУ/СШ 27 ->Проектирование цифровых систем 1, 2
Автор Сообщение
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) A = 12345;

unsigned __out __bits(16) RES;

void main()
{
int k = 0;
int prev;
int num = A;
for(int i = 0; num!=0; i++) {
prev = num;
num = prev/10;
k++;
}

RES = k*prev;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) A = 2725;

unsigned __out __bits(16) RES;

void main()
{
int k = 0;
int prev;
int num = A;
for(int i = 0; num!=0; i++) {
prev = num;
num = prev/10;
k++;
}

RES = k*prev;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) A;
unsigned __out __bits(16) RES;

void main()
{
unsigned __bits(16) temp = A;
unsigned __bits(16) count = 0;
unsigned __bits(16) first_digit;

first_digit = temp;
while (first_digit >= 10)
{
first_digit = first_digit / 10;
}

while (temp > 0)
{
count++;
temp = temp / 10;
}

RES = count * first_digit;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) A = 2725;

unsigned __out __bits(16) RES;

void main()
{
unsigned __bits(16) cnt = 0;
unsigned __bits(16) rest = A;
while (rest) {
cnt++;
RES = rest % 10;
rest /= 10;
}
RES = RES * cnt;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) a;
unsigned __out __bits(16) RES;

void main() {
unsigned __bits(16) num = a;
unsigned __bits(16) r = 0;
unsigned __bits(16) div = 1000;
unsigned __bits(16) kol = 0;

while (div > 0) {
r = r * 10 + (num % 10);
kol++;
}

RES = kol * ((num / div) % 10);
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
int __in __bits(16) A;
int __out __bits(16) RES;

void main()
{
int __bits(16) temp;
int __bits(8) digit_count;
int __bits(8) highest_digit;

temp = A;
digit_count = 0;

if (temp == 0)
{
digit_count = 1;
highest_digit = 0;
}
else
{
highest_digit = 0;
while (temp > 0)
{
int __bits(8) digit;
digit = temp % 10;
if (digit_count == 0)
{
highest_digit = digit;
}
digit_count = digit_count + 1;
temp = temp / 10;
}
}

RES = digit_count * highest_digit;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
int __in __bits(16) A;
int __out __bits(16) RES;

void main()
{
int __bits(16) num;
int __bits(8) digit_count;
int __bits(8) highest_digit;

num = A;
digit_count = 0;
highest_digit = 0;

if (num == 0)
{
digit_count = 1;
highest_digit = 0;
}
else
{
highest_digit = num;
while (highest_digit >= 10)
{
highest_digit = highest_digit / 10;
}

digit_count = 0;
while (num > 0)
{
digit_count = digit_count + 1;
num = num / 10;
}
}

RES = digit_count * highest_digit;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
int __in __bits(16) A;
int __out __bits(16) RES;

void main()
{
int __bits(16) num;
int __bits(16) count;
int __bits(16) highest_digit;

num = A;
count = 0;

// ¦Э¦-TЕ¦-¦+¦¬¦- TБTВ¦-TАTИTГTО (TБ¦-¦-TГTО ¦¬¦¦¦-TГTО) TЖ¦¬TДTАTГ
highest_digit = 0;
while (num >= 10)
{
num = num / 10;
highest_digit = num;
}

// ¦Т¦-TБTБTВ¦-¦-¦-¦-¦¬¦¬¦-¦-¦¦¦- ¦¬TБTЕ¦-¦+¦-¦-¦¦ TЗ¦¬TБ¦¬¦-
num = A;

// ¦бTЗ¦¬TВ¦-¦¦¦- ¦¦¦-¦¬¦¬TЗ¦¦TБTВ¦-¦- TЖ¦¬TДTА, TА¦-¦-¦-TЛTЕ TБTВ¦-TАTИ¦¦¦¦
while (num > 0)
{
int __bits(16) digit;
digit = num % 10;
if (digit == highest_digit)
{
count = count + 1;
}
num = num / 10;
}

// ¦ЮTБ¦-¦-TЛ¦¦ TБ¦¬TГTЗ¦-¦¦: ¦¦TБ¦¬¦¬ A = 0 (¦-¦- ¦¬¦- TГTБ¦¬¦-¦-¦¬TО 1 тЙд A тЙд 32767, ¦-¦+¦-¦-¦¦¦- ¦-¦- ¦-TБTП¦¦¦¬¦¦ TБ¦¬TГTЗ¦-¦¦)
if (A == 0)
{
count = 1;
highest_digit = 0;
}

RES = count * highest_digit;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
int A;
int RES;
int count;
int firstDigit;
int temp;

void main()
{
temp = A;
count = 0;
while (temp > 0) {
if (temp < 10) {
firstDigit = temp;
}
temp = temp / 10;
count = count + 1;
}

RES = count * firstDigit;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
int __bits(16) A = 2725;
int __bits(16) RES;

void main() {
int temp = A;
int digits = 0;
int msd = 0;

while (temp > 0) {
msd = temp % 10;
temp /= 10;
digits++;
}

RES = digits * msd;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) A = 2725;

unsigned __out __bits(16) RES;


void main() {
unsigned __bits(16) number = A;
unsigned __bits(16) digits = 0;
unsigned __bits(3) digit;

for(; number != 0; digits++) {
digit = number % 10;
number /= 10;
}

RES = digits * digit;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) A;
unsigned __out __bits(16) RES;

void main(){
unsigned high = 0;
unsigned kol = 0;
unsigned A1 = A;
while(A1 % 10 > 0){
kol++;
high = A1 % 10;
A1 /= 10;
}
RES = kol*high;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16)a=2725;

unsigned __out __bits(16)res;

void main(){
int aa=a, n=0, m=0;
if(a>=0){
m=aa;
aa=a;
n++;
}
if(a>=10){
m=aa/10;
aa=a;
n++;
}
if(a>=100){
m=aa/100;
aa=a;
n++;
}
if(a>=1000){
m=aa/1000;
aa=a;
n++;
}
if(a>=10000){
m=aa/10000;
aa=a;
n++;
}
res = m*n;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) a;
unsigned __out __bits(16) res;

void main()
{
unsigned f1 = 1;
unsigned f2 = 1;
unsigned i = 2;

if (a == 1 || a == 2) {
res = 1;
return;
}

while (i < a) {
unsigned t = f1 + f2;
f1 = f2;
f2 = t;
i++;
}

res = f2;
}
Максим Самойлович

Темы: 5
Сообщений: 152

Мой профиль
unsigned __in __bits(16) A;

unsigned __out __bits(16) RES;

void main()
{
unsigned __bits(16) a1 = A;
unsigned __bits(2) sec = 0;
unsigned __bits(3) cnt = 0;

while(a1)
{
++cnt;
sec = a1 % 10;
a1 /= 10;
}
RES = cnt * sec;
}
 
Индекс форума ->Учебный процесс ГГУ/СШ 27 ->Проектирование цифровых систем 1, 2
Time:0,016