For40. Даны целые числа A и B (A < B). Вывести все целые числа от A до B включительно; при этом число A должно выводиться 1 раз, число A + 1 должно выводиться 2 раза и т. д.
>Решение Pascal
1 2 3 4 5 6 7 8 9 10 11 | program For40; var A, B, i, i2 :Integer; begin Write('Введите A: '); Readln(A); Write('Введите B: '); Readln(B); for i:=0 to B-A do for i2:=0 to i do Writeln(A+i); end. |
>
Решение C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include int main(void) { int a,b; printf("A:"); scanf ("%i", &a); printf("B:"); scanf ("%i", &b); int i,i2; for (i =1; i<=b-a+1; ++i){ for (i2=1; i2<=i; ++i2) printf("%i ",a+i-1); printf("\n"); } return 0; } |
Решение C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> using namespace std; int main() { setlocale(LC_ALL, "Russian"); int a, b; cout<<"A:"; cin>>a; cout << "B:"; cin >> b; int i, i2; for (i = 1; i <= b - a + 1; ++i) { for (i2 = 1; i2 <= i; ++i2) cout << a + i - 1 << " "; } return 0; } |
Python
a=int(input(«Enter a:»))
b=int(input(«Enter b:»))
for i in range(1,b-a+1):
for j in range(1,i):
print(a+i-1)
#Python
a = int(input(«Type a: «))
b = int(input(«Type b: «))
for i in range(a, b + 1):
print(sep=»»)
for j in range(0, i — a + 2):
print(i, end=»»)
Скинете по с#
#include
using namespace std;
int main()
{
int a, b, c;
cout <> a;
cout <> b;
c = b — a;
for (int i = a; i <= b; i++)
{
for (int j = a; j <= i; j++)
{
cout << "i=" << i << endl;
}
}
return 0;
}
#include
using namespace std;
int main(){
int A,B;
cout<<"A (A<B) :" <>A;
cout<A) :» <>B;
int i,i2;
for(i=A; i<=B; ++i){
for(i2=A; i2<=i; ++i2)
cout<<A+i-1 <<" ";
}
return 0;
}
package main
import «fmt»
func main() {
var a, b int
fmt.Scan(&a, &b)
for i := 1; i <= b- a + 1; i++ {
for j := 1; j <= i; j++ {
fmt.Print(a + i -1)
}
}
}
int a,b;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
for (int i = a; i <= b; i++)
{
for(int j = a; j <=i ; j++)
{
Console.Write($" {i} ");
}
}