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

Темы: 2184
Сообщений: 52607

Мой профиль
unsigned __bits(8) in_str[30]; // ¦-¦-TБTБ¦¬¦- TБ TГ¦¦¦-¦¬¦-¦-¦¬¦¦¦- TА¦-¦¬¦-¦¦TА¦-
unsigned __out __bits(8) res; // TБTГ¦-¦-¦- TЖ¦¬TДTА (1 ¦-¦-¦¦TВ)

void main()
{
unsigned __bits(8) sum = 0;
unsigned __bits(8) i = 0;
unsigned __bits(8) current_char;

while (1) {
current_char = in_str[i];

if (current_char == '*' || current_char == 0) {
break;
}

if (current_char >= 48 && current_char <= 57) {
sum = sum + (current_char - 48);
}

i = i + 1;

if (i >= 20) break; // ¦¬¦-TЙ¦¬TВ¦- ¦-TВ ¦-TЛTЕ¦-¦+¦- ¦¬¦- ¦¦TА¦-¦-¦¬TЖTЛ
}

res = sum;
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
unsigned __bits(8) in_str[20]; // ¦-¦-TБTБ¦¬¦- TБ TГ¦¦¦-¦¬¦-¦-¦¬¦¦¦- TА¦-¦¬¦-¦¦TА¦-
unsigned __out __bits(8) res; // TБTГ¦-¦-¦- TЖ¦¬TДTА (1 ¦-¦-¦¦TВ)

void main()
{
unsigned __bits(8) sum = 0;
unsigned __bits(8) i = 0;
unsigned __bits(8) current_char;

while (1) {
current_char = in_str[i];

if (current_char == '*' || current_char == 0) {
break;
}

if (current_char >= 48 && current_char <= 57) {
sum = sum + (current_char - 48);
}

i = i + 1;

if (i >= 20) break; // ¦¬¦-TЙ¦¬TВ¦- ¦-TВ ¦-TЛTЕ¦-¦+¦- ¦¬¦- ¦¦TА¦-¦-¦¬TЖTЛ
}

res = sum;
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
unsigned __in __bits(8) IN0;
unsigned __in __bits(8) IN1;
unsigned __in __bits(8) IN2;
unsigned __in __bits(8) IN3;
unsigned __in __bits(8) IN4;
unsigned __in __bits(8) IN5;
unsigned __in __bits(8) IN6;
unsigned __in __bits(8) IN7;
unsigned __in __bits(8) IN8;
unsigned __in __bits(8) IN9;
unsigned __in __bits(8) IN10;
unsigned __in __bits(8) IN11;
unsigned __in __bits(8) IN12;
unsigned __in __bits(8) IN13;
unsigned __in __bits(8) IN14;
unsigned __in __bits(8) IN15;

unsigned __out __bits(8) res;

void main()
{
unsigned __bits(8) sum = 0;

// ¦ЯTА¦-¦-¦¦TАTП¦¦¦- ¦¬¦-TБ¦¬¦¦¦+¦-¦-¦-TВ¦¦¦¬TМ¦-¦- ¦+¦- TБ¦¬¦-¦-¦-¦¬¦- '*'
if (IN0 != '*' && IN0 != 0) {
if (IN0 >= 48 && IN0 <= 57) sum = sum + (IN0 - 48);
if (IN1 != '*' && IN1 != 0) {
if (IN1 >= 48 && IN1 <= 57) sum = sum + (IN1 - 48);
if (IN2 != '*' && IN2 != 0) {
if (IN2 >= 48 && IN2 <= 57) sum = sum + (IN2 - 48);
if (IN3 != '*' && IN3 != 0) {
if (IN3 >= 48 && IN3 <= 57) sum = sum + (IN3 - 48);
if (IN4 != '*' && IN4 != 0) {
if (IN4 >= 48 && IN4 <= 57) sum = sum + (IN4 - 48);
if (IN5 != '*' && IN5 != 0) {
if (IN5 >= 48 && IN5 <= 57) sum = sum + (IN5 - 48);
if (IN6 != '*' && IN6 != 0) {
if (IN6 >= 48 && IN6 <= 57) sum = sum + (IN6 - 48);
if (IN7 != '*' && IN7 != 0) {
if (IN7 >= 48 && IN7 <= 57) sum = sum + (IN7 - 48);
if (IN8 != '*' && IN8 != 0) {
if (IN8 >= 48 && IN8 <= 57) sum = sum + (IN8 - 48);
if (IN9 != '*' && IN9 != 0) {
if (IN9 >= 48 && IN9 <= 57) sum = sum + (IN9 - 48);
if (IN10 != '*' && IN10 != 0) {
if (IN10 >= 48 && IN10 <= 57) sum = sum + (IN10 - 48);
if (IN11 != '*' && IN11 != 0) {
if (IN11 >= 48 && IN11 <= 57) sum = sum + (IN11 - 48);
if (IN12 != '*' && IN12 != 0) {
if (IN12 >= 48 && IN12 <= 57) sum = sum + (IN12 - 48);
if (IN13 != '*' && IN13 != 0) {
if (IN13 >= 48 && IN13 <= 57) sum = sum + (IN13 - 48);
if (IN14 != '*' && IN14 != 0) {
if (IN14 >= 48 && IN14 <= 57) sum = sum + (IN14 - 48);
if (IN15 != '*' && IN15 != 0) {
if (IN15 >= 48 && IN15 <= 57) sum = sum + (IN15 - 48);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

res = sum;
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
unsigned __bits(8) in_str[]; // ¦-¦-TБTБ¦¬¦- ¦-¦¦¦¬ __in
unsigned __out __bits(8) res; // TБTГ¦-¦-¦- TЖ¦¬TДTА (1 ¦-¦-¦¦TВ)

void main()
{
unsigned __bits(8) sum = 0;
unsigned __bits(8) i = 0;
unsigned __bits(8) current_char;

while (1) {
current_char = in_str[i];

if (current_char == '*' || current_char == 0) {
break;
}

if (current_char >= 48 && current_char <= 57) {
sum = sum + (current_char - 48);
}

i = i + 1;
}

res = sum;
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
char in_str[128];

unsigned __out __bits(16) res;

void main()
{
int __bits(16) cnt = 0;
for (int i = 0; in_str[i] != '*'; i++) {
if (in_str[i] == '1') cnt += 1;
if (in_str[i] == '2') cnt += 2;
if (in_str[i] == '3') cnt += 3;
if (in_str[i] == '4') cnt += 4;
if (in_str[i] == '5') cnt += 5;
if (in_str[i] == '6') cnt += 6;
if (in_str[i] == '7') cnt += 7;
if (in_str[i] == '8') cnt += 8;
if (in_str[i] == '9') cnt += 9;
}
res = cnt;
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
char in_str[128];

int __out __bits(16) res;

void main()
{
int __bits(16) cnt = 0;
for (int i = 0; in_str[i] != '#'; i++) {
if (in_str[i] == '1') cnt += 1;
if (in_str[i] == '2') cnt += 2;
if (in_str[i] == '3') cnt += 3;
if (in_str[i] == '4') cnt += 4;
if (in_str[i] == '5') cnt += 5;
if (in_str[i] == '6') cnt += 6;
if (in_str[i] == '7') cnt += 7;
if (in_str[i] == '8') cnt += 8;
if (in_str[i] == '9') cnt += 9;
}
res = cnt;
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
char in_str[129]="qw12*1";
int __out __bits(8) res;

void main(){
int i=0;
int c=0;
int len=0;
while ((in_str[len]!='*')&&(len<129)){
len++;
}
for (i=0; i<len; i++){
if (in_str[i]>='0' && in_str[i]<='9')
c=c+in_str[i];
}
res=c;
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
char in_str[128];
unsigned __out __bits(8) res;

void main() {
res = 0;
int i = 0;
while (in_str[i] != '*') {
if (in_str[i] >= '9' && in_str <= '9') {
res += in_str[i] - '0';
}
i++;
}
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
char in_str[128];
unsigned __out __bits(8) res;

void main() {
res = 0;
int i = 0;
while (in_str[i] != '*' && in_str[i] != '\0') {
if (in_str[i] >= '9' && in_str <= '9') {
res += in_str[i] - '0';
}
i++;
}
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
char in_str[128];
unsigned __out __bits(8) res;

void main() {
int res = 0;
int i = 0;
while (in_str[i] != '*' && in_str[i] != '\0') {
if (in_str[i] >= '9' && in_str <= '9') {
res += in_str[i] - '0';
}
i++;
}
}
Михаил Долинский

Темы: 2184
Сообщений: 52607

Мой профиль
char in_str[128];
unsigned __out __bits(16) res;

void main() {
int res = 0;
int i = 0;
while (in_str[i] != '*' && in_str[i] != '\0') {
if (in_str[i] >= '9' && in_str <= '9') {
res += in_str[i] - '0';
}
i++;
}
}
 
Индекс форума ->Учебный процесс ГГУ/СШ 27 ->Проектирование цифровых систем
Time:0,012