1. zadatak #include #include using namespace std; int main() { ofstream out("res.txt"); if (!out) { cout << "nije moguce" << endl; return 1; } double rad; cout << "Radijus:"; cin >> rad; double v = 4 * 3.14 * pow(rad, 3) / 3; double p = 4 * 3.14 * pow(rad, 2); out << "Radijus:" << rad << endl; out << "Volumen:" << v << endl; out << "Povrsina:" << p << endl; out.close(); return 0; } __________________________________________________________ 2. zadatak #include #include using namespace std; bool prost(int broj) { if (broj == 1) { return false; } for (int i = 2; i <= broj/2; i++) { if (broj % i ==0) { return false; } } return true; } int main() { ifstream in("tekst.txt"); ofstream out("prosti.txt"); if (!in||!out) { cout << "can't do" << endl; return 1; } int broj; while (in >> broj) { if (prost(broj)) { out << broj << endl; } } in.close(); out.close(); return 0; } _____________________________________________________ 3. zadatak #include #include #include using namespace std; int main() { ifstream in("tekst.txt"); ofstream parni("parni.txt"); ofstream neparni("neparni.txt"); if (!in||!parni||!neparni) { cout << "can't do" << endl; return 1; } vector v; int broj; while (in >> broj) { v.push_back(broj); } for (int i = v.size()-1; i >= 0; i--) { if (v[i] % 2 == 0) { parni << v[i] << endl; } else { neparni << v[i] << endl; } } in.close(); parni.close(); neparni.close(); return 0; }