Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Podzielnosc 7 4 3 11
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- bool podzielnosc11(int liczba){
- int suma;
- while (liczba>0){
- suma=liczba%10+(liczba%100-liczba%10);
- if(suma%11==0)
- return true;
- return false;
- }
- }
- using namespace std;
- bool podzielnosc2(int liczba){
- int suma;
- suma=liczba%10;
- if(suma%2==0) return true;
- return false;
- }
- bool podzielnosc3 (int liczba) {
- int suma;
- while (liczba>0) {
- suma=suma+liczba%10;
- liczba=liczba/=10;
- }
- if (suma%3==0) return true;
- return false;
- }
- bool podzielnosc7 (int liczba){
- int suma=0;
- int i=1;
- while (liczba>0){
- if (i%2==1)
- suma=suma+liczba%1000;
- else
- suma=suma-liczba%1000;
- liczba=liczba/1000;
- i++;
- }
- if(suma%7==0)
- return true;
- return false;
- }
- bool podzielnosc4 (int liczba){
- int suma;
- suma=liczba%10+2*liczba%100;
- if(suma%4==0) return true;
- return false;
- }
- int main(int argc, char *argv[])
- {
- fstream dane,wynik;
- dane.open ("dane.txt", ios::in);
- wynik.open ("wynik.txt", ios::out);
- int n;
- while (!dane.eof()){
- dane>>n;
- if (podzielnosc7 (n)==true)wynik<<n<<endl;
- }
- dane.close ();
- wynik.close ();
- system("PAUSE");
- return EXIT_SUCCESS;
- }
- //Schody
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- fstream dane,wynik;
- dane.open("dane.txt", ios::in);
- wynik.open("wynik.txt", ios::out);
- int n,k=0, liczba=n, i=1;
- while(!dane.eof())
- {
- dane>>n;
- if(n<=liczba)
- {
- liczba=n;
- i++;
- if(i>=k)
- k=i;
- }
- else
- {
- i=1; (
- liczba=n;
- }
- }
- cout<<k;
- dane.close();
- wynik.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement