Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ряды
- #include <iostream>
- #include<cmath>
- using namespace std;
- int main() {
- int A[10];
- int n;
- int count=0;
- for(int i=0;i<10;i++){
- A[i]=rand()%10;
- cout<<A[i]<<" ";
- }
- cout<<endl;
- cin>>n;
- for(int i=0;i<10;i++){
- if(A[i]==n){
- count+=1;
- cout<<i<<" ";
- }
- }
- cout<<count;
- return 0;
- }
- Евклид
- #include<iostream>
- #include<cmath>
- using namespace std;
- int main(){
- int a;
- int b;
- int c;
- cin>>a>>b;
- while(b){
- c=a%b;
- a=b;
- b=c;
- }
- cout<< abs(a);
- }
- Эратосфен
- #include <iostream>
- using namespace std;
- int main () {
- int n,i;
- cin>>n;
- for (i=2; i<=n; i++) {
- if ((i%2)!=0 && (i%3)!=0 && (i%5)!=0 && (i%7)!=0 || i==2 || i==3 || i==5 || i==7)
- cout<<i<<' ';
- }
- return 0;
- }
- Файлы текстовые
- #include<iostream>
- #include<sstream>
- #include<string>
- #include<fstream>
- using namespace std;
- int main(){
- ofstream fout;
- fout.open("zadacha.txt");
- fout<<"Своя хуйня";
- fout.close();
- ifstream fin;
- fin.open("zadacha.txt");
- string s;
- getline(fin, s);
- for (int i = 0; i < s.length(); ++i) {
- cout << s[i] << endl;
- }
- fin.close();
- system("pause");
- return 0;
- }
- Файлы
- #include <iostream>
- #include<iomanip>
- using namespace std;
- double determinant(double a[][2])
- {
- return a[0][0]*a[1][1]-a[0][1]*a[1][0];
- }
- int main()
- {
- setlocale(LC_ALL,"Russian");
- const int size=2;
- double matrix[size][size];
- cout<<"Значения элементов "<<endl;
- for(int i=0;i<size;i++)
- {
- for(int j=0;j<size;j++)
- {
- cin>>matrix[i][j];
- }
- }
- for(int k=0;k<1;k++){
- for(int m=0;m<1;m++){
- cout<<"->"<<matrix[0][0]<<" "<<matrix[0][1]<<endl;
- cout<<"->"<<matrix[1][1]<<" "<<matrix[1][0]<<endl;
- }
- }
- for(int t=0;t<1;t++){
- for(int q=0;q<1;q++){
- cout<<fixed<<setprecision(2)<<matrix[0][0]<<" "<<setprecision(2)<<matrix[0][1]<<endl;
- cout<<fixed<<setprecision(2)<<matrix[1][1]<<" "<<setprecision(2)<<matrix[1][0]<<endl;
- }
- }
- cout<<"\n\nОпределитель "<<fixed<<setprecision(2)<<determinant(matrix)<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement