Advertisement
wilk_maciej

Ćwiczcenia 1 C++

Feb 26th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4.  
  5. class klasa{
  6.     public:
  7.     int a, b;
  8.     double c;
  9.     double funkcja(int zmienna){
  10.         return c * zmienna;
  11.     }
  12. };
  13.  
  14. class czas{
  15.     int godz, min, sec;
  16.     public:
  17.     void ZAPAMIETAJCZAS (int g, int m, int s){
  18.         godz=g;
  19.         min=m;
  20.         sec=s;
  21.     }
  22.     void ZAPAMIETAJCZAS (char *cz){
  23.        
  24.         sscanf(cz,"%2d:%2d:%2d", &godz, &min, &sec);
  25.     }
  26.  
  27.     void ZWROCCZAS (int &g, int &m, int &s){
  28.         g = godz;
  29.         m = min;
  30.         s = sec;
  31.     }
  32.  
  33.     void ZWROCCZAS (char *cz){
  34.         sprintf(cz, "%2d:%2d:%2d", godz, min, sec);
  35.     }
  36. };
  37.  
  38.  
  39. int main(){
  40.     /*class klasa g;
  41.     g.c=10;
  42.     int a1=89;
  43.     double zm1;
  44.     zm1= g.funkcja(a1);
  45.     cout <<zm1;
  46.     cout << endl;
  47.     return 0;
  48.     */
  49.     int z1=223;
  50.     int z2=1322;
  51.     int z3=1333;
  52.     char bufor[100]="CZAS: ";
  53.     char czas[]="21:37:05";
  54.     class czas zegar;
  55.     zegar.ZAPAMIETAJCZAS(21,32,13);
  56.     zegar.ZWROCCZAS(z1,z2,z3);
  57.     cout <<z1 <<":" <<z2 <<":" <<z3;
  58.     zegar.ZAPAMIETAJCZAS(czas);
  59.     zegar.ZWROCCZAS(bufor);
  60.     cout << endl << bufor;
  61.    
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement