Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // zadacha 1
- // тук програмата извежда броя на чифрите на въведеното число.
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int num;
- int digit = 0 ;
- cout << "Enter number:" << endl;
- cin >> num;
- do
- {
- num = num / 10;
- digit++;
- } while (num != 0);
- cout << "Number of digits in the given integer is: " << digit;
- }
- задача 2:
- // zadacha 2
- // тук програмата извежда сбора на числата на въведеното число.
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int num;
- int digit = 0 ;
- cout << "Enter number:" << endl;
- cin >> num;
- while (num != 0) {
- digit = digit + num % 10;
- num = num / 10;
- }
- cout << "Number of digits in the given integer is: " << digit;
- }
- задача 3:
- // zadacha 3
- //
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int a;
- int num;
- int c = 0;
- cout << "Enter number:" << endl;
- cin >> num;
- while (num != 0) {
- a = num % 10;
- c = c * 10 + a;
- num = num / 10;
- }
- cout << "Number of digits in the given integer is: " << c;
- }
- задача 4 :
- // zad 4 lab.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int givenNum;
- cout << "Enter number:";
- cin >> givenNum;
- int current;
- int currentcounter = 0;
- int numbers[10] = { 0,1,2,3,4,5,6,7,8,9 };
- for (int i = 0; i < 10; i++) {
- while (givenNum > 0) {
- if ((givenNum % 10) == numbers[i]) {
- currentcounter++;
- }
- givenNum = givenNum / 10;
- }
- cout << numbers[i] << "/" << currentcounter << endl;
- currentcounter = 0;
- }
- return 0;
- }
- задача 5 :
- // Dom rabota zad 5 lekciya .cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- int main()
- {
- char symbol;
- int rowcount;
- int space;
- cout << "Enter a symbol:";
- cin >> symbol;
- cout << "Enter row number:" << endl;
- cin >> rowcount;
- for (size_t i = 0; i < rowcount; i++) {
- for (space = 1; space <= rowcount - i; ++space) {
- cout << " ";
- }
- for (int j = 0; j < 1; j++) {
- cout << symbol;
- cout << " ";
- }
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement