Advertisement
abs25

LV-14

Jan 13th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <string>
  4. #include <ctype.h>
  5. #include <math.h>
  6. #include <time.h>
  7.  
  8. using namespace std;
  9.  
  10. inline float funkcija(int x1, int x2)
  11. {
  12.     return exp(x1*x2) - pow(x1, 3) + pow(x2, 4) + sqrt(pow(x1, 2) + pow(x2, 2));
  13. }
  14.  
  15. int main(void)
  16. {
  17.     float p[200], dest[100];
  18.     int dg = -5, gg = 10;
  19.  
  20.     srand((unsigned)time(NULL));
  21.  
  22.     for (int i = 0; i < 200; i++)
  23.         p[i] = (float)i;                //dg + (float)rand() / RAND_MAX * (gg - dg);
  24.  
  25.     memcpy(&dest, &p[50], 100*sizeof(float));
  26.  
  27.     for (int i = 0; i < 100; i++)
  28.         printf("%.2f\n", dest[i]);
  29.  
  30.     printf("\n======================================== 2. ZADATAK\n\n");
  31.     string str;
  32.     int br = 0;
  33.     do
  34.     {
  35.         printf("Unesite string u rasponu od 8 do 15 slova: ");
  36.         getline(cin, str);
  37.     } while (str.length() < 8 || str.length() > 15);
  38.  
  39.     size_t found = str.find_first_of("aeiou");
  40.     while (found != std::string::npos)
  41.     {
  42.         br++;
  43.         found = str.find_first_of("aeiou", found + 1);
  44.     }
  45.    
  46.     printf("Broj samoglasnika u stringu: %d\n", br);
  47.  
  48.    
  49.     printf("\n======================================== 3. ZADATAK\n\n");
  50.     int x1 = 0, x2 = 0;
  51.     printf("Unesite x1: ");
  52.     scanf("%d", &x1);
  53.     printf("Unesite x2: ");
  54.     scanf("%d", &x2);
  55.     printf("vrijednost iznosi: %.2f\n", funkcija(x1, x2));
  56.  
  57.     getchar();
  58.     printf("\n======================================== 4. ZADATAK\n\n");
  59.     string st;
  60.     printf("Unesite string sa brojevima: ");
  61.     getline(cin, st);
  62.     int num = 0;
  63.     for (int i = 0; i<st.size(); i++)
  64.         if (isdigit(st[i])) num++;
  65.     cout << "Broj znamenaka iznosi: " << num << endl;
  66.  
  67.     return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement