skvik71672
?>

С какого цикла можно решить задачу суммирования чисел от 1 до 1000? For While И For и While подойдет

Информатика

Ответы

Pogosyan Nataliya

i=1

c=2

while i<1000:

   i=i+1

   c=c+i

print("c")

Объяснение:

вроде так

SitnikovYurii5

#include <iostream>

#include <vector>

#include <cmath>

using namespace std;

struct river{

   string name;

   double length;

   double depth;

   bool ships;

};

signed main(){

   int n;

   cin >> n;

   river a[n];

   for(int i = 0; i < n; i++)

       cin >> a[i].name >> a[i].length >> a[i].depth >> a[i].ships;

   vector<river> ans;

   for(auto i: a)

       if(i.length > 2 && i.ships)

           ans.push_back(i);

   for(auto i: ans){

       cout << "name: " << i.name << "\n";

       cout << "length: " << i.length << "\n";

       cout << "depth: " << i.depth << "\n";

       cout << "ships?: Yes";

   }

}

Рожнов

#include <iostream>

#include <vector>

#include <cmath>

using namespace std;

struct river{

   string name;

   double length;

   double depth;

   bool ships;

};

signed main(){

   int n;

   cin >> n;

   river a[n];

   for(int i = 0; i < n; i++)

       cin >> a[i].name >> a[i].length >> a[i].depth >> a[i].ships;

   vector<river> ans;

   for(auto i: a)

       if(i.length > 2 && i.ships)

           ans.push_back(i);

   for(auto i: ans){

       cout << "name: " << i.name << "\n";

       cout << "length: " << i.length << "\n";

       cout << "depth: " << i.depth << "\n";

       cout << "ships?: Yes";

   }

}

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

С какого цикла можно решить задачу суммирования чисел от 1 до 1000? For While И For и While подойдет
Ваше имя (никнейм)*
Email*
Комментарий*