Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Zadacha 1:
- #include <iostream>
- using namespace std;
- int main() {
- int i = 0;
- unsigned int n;
- cout << "Vuvedete chislo" << endl;
- cin >> n;
- while (n > 0)
- {
- n = n / 10;
- i++;
- }
- cout << i << endl;
- return 0;
- }
- Zadacha 2:
- #include <iostream>
- using namespace std;
- int main() {
- int sum = 0, y = 0;
- int i = 0;
- unsigned int n;
- cout << "Vuvedete chislo" << endl;
- cin >> n;
- while (n > 0)
- {
- y = n % 10;
- sum += y;
- n = n / 10;
- }
- cout << sum << endl;
- return 0;
- }
- Zadacha 3
- #include <iostream>
- using namespace std;
- int main() {
- int sum = 0, y = 0;
- int i = 0;
- unsigned int n;
- cout << "Vuvedete chislo" << endl;
- cin >> n;
- while (n > 0)
- {
- y = n % 10;
- sum = sum * 10 + y;
- n = n / 10;
- }
- cout << sum << endl;
- return 0;
- }
- Zadacha 4:
- #include <iostream>
- using namespace std;
- int main() {
- int for0 = 0, for1 = 0, for2 = 0 ,for3 = 0 , for4 = 0, for5 = 0, for6 = 0, for7 = 0, for8 = 0, for9 = 0;
- int y = 0;
- unsigned int n;
- cout << "Vuvedete chislo" << endl;
- cin >> n;
- while (n > 0)
- {
- y = n % 10;
- if (y == 0)
- {
- for0++;
- }
- if (y == 1)
- {
- for1++;
- }
- if (y == 2)
- {
- for2++;
- }
- if (y == 3)
- {
- for3++;
- }
- if (y == 4)
- {
- for4++;
- }
- if (y == 5)
- {
- for5++;
- }
- if (y == 6)
- {
- for6++;
- }
- if (y == 7)
- {
- for7++;
- }
- if (y == 8)
- {
- for8++;
- }
- if (y == 9)
- {
- for9++;
- }
- n = n / 10;
- }
- cout << " 0/" << for0 << " 1/" << for1 << " 2/" << for2 << " 3/" << for3 << " 4/" << for4 << " 5/" << for5 << " 6/" << for6
- << " 7/" << for7 << " 8/" << for8 << " 9/" << for9 << endl;
- return 0;
- }
- Zadacha 5:
- #include <iostream>
- using namespace std;
- int main() {
- unsigned int colums;
- char sumbol = 'a';
- cout << "Vuvedete simvol i broi redove" << endl;
- cin >> sumbol >> colums;
- int j, k = 0;
- for (int i = 1; i <= colums ; i++)
- {
- for (j = colums - 1; j >= i; j--) {
- cout << " ";
- }
- for (k = 1; k <= (2 * i - 1); k++) {
- cout << sumbol;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement