Ifstream file("students txt")
Download 63.14 Kb.
|
Dasturlash V4
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETINING DASTURIY INJINIRING FAKULTETI TALABASI LOCHINBEK ALMURADOVNING DASTURLASH II FANIDAN LABARATORIYA ISHI TOSHKENT 2023
#include #include #include using namespace std; struct Student { string last_name; string first_name; int age; }; bool operator<(const Student& a, const Student& b) { return a.first_name < b.first_name; } int main() { ifstream file("students.txt"); int n; file >> n; set for (int i = 0; i < n; i++) { Student student; file >> student.last_name >> student.first_name >> student.age; students.insert(student); } for (auto student : students) { cout << student.first_name << " " << student.last_name << ", " << student.age << endl; } return 0; } N ta complex son berilgan. Ularning mavhum qismlari tasodifiy toq sonlar bilan to'ldirilsin han1da ushbu N ta coplex sonning yig'indisi topilsin. #include using namespace std; int main(){ complex int N; cin>>N; srand(time(NULL)); complex for(int i = 0; i < N; i++){ if((rand()%100+i)%2!=0){ a.imag(rand()%100+i); sum+=a; cout< }
#include using namespace std; int main() { cout << "1-topshiriq\n"; complex complex cout << "a+b" << a + b; cout << "\n2-topshiriq\n"; valarray for (int i = 0; i < arr.size(); i++) { arr[i] = rand() % 10; } // Massivni slice'lar orqali juft va toq sonlarga ajratish valarray valarray cout << "Array: "; for (int i = 0; i < arr.size(); i++) { cout << arr[i] << " "; } cout << endl; cout << "Even elements: "; for (int i = 0; i < even.size(); i++) { cout << even[i] << " "; } cout << endl; cout<<"\n3-topshiriq\n"; valarray for (int i = 0; i < 50; i++) { arr1[i] = i; } // gslice obyekti yaratamiz size_t size = 5; size_t stride = 6; valarray valarray arr1[gslice(0, lengths, strides)]=10; // Natijani chop etamiz for (int i = 0; i < size*size; i++) { cout << arr1[i] << " "; } cout << endl; return 0; } Download 63.14 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling