Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <string>
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "rus");
- char buffstr[100];
- ifstream fin("text.txt");
- while (!fin.eof())
- {
- string s;
- getline(fin, s);
- int flag = -1;
- int j = 0, i = 0;
- while (s[i]) {
- if (s[i] == '"')
- if (flag < 0) flag = i;
- else
- {
- for (j = flag; j <= i; j++) cout << s[j];
- cout << " ";
- flag = -1;
- }
- i++;
- }
- }
- cout << endl;
- fin.close();
- system("pause");
- return 0;
- }
- 1) #include <iostream>
- using namespace std;
- int nod(int a, int b)
- {
- while (a != b) {
- if (a > b) {
- int tmp = a;
- a = b;
- b = tmp;
- }
- b = b - a;
- }
- return a;
- }
- long nod(long a, long b)
- {
- while (a != b) {
- if (a > b) {
- long tmp = a;
- a = b;
- b = tmp;
- }
- b = b - a;
- }
- return a;
- }
- float nod(float a, float b)
- {
- while (a != b) {
- if (a > b) {
- float tmp = a;
- a = b;
- b = tmp;
- }
- b = b - a;
- }
- return a;
- }
- double nod(double a, double b)
- {
- while (a != b) {
- if (a > b) {
- double tmp = a;
- a = b;
- b = tmp;
- }
- b = b - a;
- }
- return a;
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- cout << "Введите два int числа: ";
- int ia, ib;
- cin >> ia >> ib;
- cout << "НОД = " << nod(ia, ib) << endl;
- cout << "Введите два long числа: ";
- long la, lb;
- cin >> la >> lb;
- cout << "НОД = " << nod(la, lb) << endl;
- cout << "Введите два float числа: ";
- int fa, fb;
- cin >> fa >> fb;
- cout << "НОД = " << nod(fa, fb) << endl;
- cout << "Введите два double числа: ";
- double da, db;
- cin >> da >> db;
- cout << "НОД = " << nod(da, db) << endl;
- system("pause");
- return 0;
- }
- 2) #include <iostream>
- using namespace std;
- template <class array_type>
- array_type sum(array_type *a, int n)
- {
- array_type s = 0;
- for (int i = 0; i < n; i++)
- {
- s += a[i];
- }
- return s;
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- int a[10] = {};
- float b[10] = {};
- double c[10] = {};
- cout << "Введите N = ";
- int n;
- cin >> n;
- cout << "\nВведите int массив ";
- for (int i = 0; i < n; i++) cin >> a[i];
- cout << "\n Сумма = " << sum(a, n);
- cout << "\nВведите float массив ";
- for (int i = 0; i < n; i++) cin >> b[i];
- cout << "\n Сумма = " << sum(b, n);
- cout << "\nВведите double массив ";
- for (int i = 0; i < n; i++) cin >> c[i];
- cout << "\n Сумма = " << sum(c, n) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement