- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculateInt.html
More file actions
Latest commit
89 lines (77 loc) · 1.84 KB
/
Copy pathcalculateInt.html
File metadata and controls
89 lines (77 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<html>
<head>
<title>Сложение больших чисел</title>
</head>
<body>
<style>
.input-block {
margin:10px;
}
</style>
<script>
varcalculate=function(){
vars1=document.getElementById("int1").value;
vars2=document.getElementById("int2").value;
vars='';
varn1,n2,n3,l1,l2,i;
varc='';
l1=s1.length;
l2=s2.length;
if(l1>l2){
s3=s1;
l3=l1;
s1=s2;
l1=l2;
s2=s3;
l2=l3;
}
s3='';
n3=0;
for(i=l1;i>=1;i--){
n1=parseInt(s1.charAt(i-1));
n2=parseInt(s2.charAt(l2-1));
l2=l2-1;
c=(n1+n2+n3)%10;
s3=c+s3;
if(n1+n2+n3>9){
n3=1
}
else{
n3=0;
}
}
while(n3==1){
if(l2!=0){
n2=parseInt(s2.charAt(l2-1));
l2=l2-1;
c=(n2+n3)%10;
s3=c+s3;
if((n2+n3)<10){
n3=0;
}
}
else{
s3='1'+s3;
n3=0;
}
}
if(l2!=0){
s3=s2.substring(0,l2)+s3;
}
console.log('Сумма чисел равна: '+s3);
alert('Сумма чисел равна: '+s3);
}
</script>
<divclass="input-block">
<span>Первое число</span><br>
<inputid="int1">
</div>
<divclass="input-block">
<span>Второе число</span><br>
<inputid="int2">
</div>
<divclass="input-block">
<buttononclick="calculate()">Посчитать сумму</button>
</div>
</body>
</html>