Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include<string>
- int const num = 2;
- const string character = ".";
- struct Streets {
- string name;
- double lenght;
- int numofsvetofari;
- };
- void readStreets (Streets & s) {
- cout << " danni za ulica:\n";
- do {
- cout << " ime na ulica: ";
- cin >> s.name;
- } while (s.name.find != string::npos)
- do {
- cout << " dyljina na ulica: ";
- cin >> s.lenght;
- } while (s.lenght < 0);
- do {
- cout << " broi na svetofari na ulica: ";
- cin >> s.numofsvetofari;
- } while (s.numofsvetofari < 0);
- }
- void writeStreets(Streets s) {
- cout << " Ime na ulica: " << s.name << "\n"
- << "Dyljina na ulica " << s.lenght << "\n"
- <<"Broi na svetofari: " << s.numofsvetofari << endl;
- }
- void readMas(Streets c[], int M) {
- cout << "Vyvedete danni za ulicata: "<< M << " :\n";
- for (int i = 0; i < M; ++i) {
- cout << i + 1 <<"\n";
- readStreets(c[i]);
- }
- }
- int main() {
- system("chcp 1251");
- Streets ar[num];
- readMas(ar, num);
- for (Streets s : ar) {
- if (s.numofsvetofari == 0) {
- cout << "Ulici bez svetofari: << \n ";
- writeStreets(s);
- }
- }
- string podniz;
- cout << "Въведете търсен подниз: ";
- getline(cin, podniz);
- cout << "Ulici название, съдържащо uj \"" << podniz << "\":\n";
- for (Streets s : ar)
- if (s.name.find(podniz) == "uj")
- writeStreets(s);
- cout << " (край)\n\n";
- system("pause");
- string podniz;
- cout << "Wywedi podniz: ";
- getline(cin, podniz);
- for (Goods g : ar)
- if (s.name.find(podniz) == "uj")
- writeGoods(g);
- if (s.name == "юж") {
- cout << "Ulici s nazwanie,sydyrjashto uj \"" << podniz << "\":\n";
- for (Streets s : ar)
- writeStreets(s);
- }
- system("pause");
- }
- // Файл progr19_09_04.cpp към Задача 9.04
- #include <iostream>
- using namespace std;
- #include <string>
- int const number = 3; // брой на стоките
- const string chAll = "0123456789 ,.-"
- "абвгдежзийклмнопрстуфхцчшщъьюя"
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- //допустими знакове в названието на стока
- struct Goods {
- string kind;
- double price;
- };
- void readGoods(Goods & g) { // задължително със знак &
- cout << " данни за стока:\n";
- do {
- cout << " цена: ";
- cin >> g.price;
- } while (g.price <= 0.0);
- getline(cin, g.kind); // изчиства буфера на клавиатурата
- do {
- cout << " название: ";
- getline(cin, g.kind);
- } while (g.kind == "" ||
- string::npos != g.kind.find_first_not_of(chAll));
- }
- void writeGoods(Goods g) {
- cout << " Стока: " << g.kind
- << "; цена: " << g.price << endl;
- }
- void readAarray(Goods a[], int L) {
- cout << "Въвеждайте данни за " << L << " стоки:\n";
- for (int i = 0; i < L; ++i) {
- cout << " " << i + 1 << ".";
- readGoods(a[i]);
- }
- }
- int main() {
- system("chcp 1251");
- Goods ar[number];
- readAarray(ar, number);
- double max = 0.0;
- for (Goods g : ar)
- if (g.price > max)
- max = g.price;
- cout << "Максимална цена: " << max
- << "\nСтоки с тасзи цена:\n";
- for (Goods g : ar)
- if (g.price == max)
- cout << " " << g.kind << endl;
- string podniz;
- cout << "Въведете търсен подниз: ";
- getline(cin, podniz);
- cout << "Ulici название, съдържащо uj \"" << podniz << "\":\n";
- for (Streets s : ar)
- if (s.name.find(podniz) == "uj")
- writeStreets(s);
- cout << " (край)\n\n";
- system("pause");
- }
- // Файл progr19_09_04.cpp към Задача 9.04
- #include <iostream>
- using namespace std;
- #include <string>
- int const number = 3; // брой на стоките
- const string chAll = "0123456789 ,.-"
- "абвгдежзийклмнопрстуфхцчшщъьюя"
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- //допустими знакове в названието на стока
- struct Goods {
- string kind;
- double price;
- };
- void readGoods(Goods & g) { // задължително със знак &
- cout << " данни за стока:\n";
- do {
- cout << " цена: ";
- cin >> g.price;
- } while (g.price <= 0.0);
- getline(cin, g.kind); // изчиства буфера на клавиатурата
- do {
- cout << " название: ";
- getline(cin, g.kind);
- } while (g.kind == "" ||
- string::npos != g.kind.find_first_not_of(chAll));
- }
- void writeGoods(Goods g) {
- cout << " Стока: " << g.kind
- << "; цена: " << g.price << endl;
- }
- void readAarray(Goods a[], int L) {
- cout << "Въвеждайте данни за " << L << " стоки:\n";
- for (int i = 0; i < L; ++i) {
- cout << " " << i + 1 << ".";
- readGoods(a[i]);
- }
- }
- int main() {
- system("chcp 1251");
- Goods ar[number];
- readAarray(ar, number);
- double max = 0.0;
- for (Goods g : ar)
- if (g.price > max)
- max = g.price;
- cout << "Максимална цена: " << max
- << "\nСтоки с тасзи цена:\n";
- for (Goods g : ar)
- if (g.price == max)
- cout << " " << g.kind << endl;
- string sub;
- cout << "Въведете търсен подниз: ";
- getline(cin, sub);
- cout << "Стоки с название, съдържащо \"" << sub << "\":\n";
- for (Goods g : ar)
- if (g.kind.find(sub) != string::npos)
- writeGoods(g);
- cout << " (край)\n\n";
- system("pause");
- }
- #include<iostream>
- #include<string>
- using namespace std;
- int main()
- {
- system("chcp 1251");
- string str, sub;
- cout << "Wywedete 1-niz: ";
- getline(cin, str);
- cout << "Wywedete 2-niz: ";
- getline(cin, sub);
- int inumber = 0;
- if(str.substr(begin,len))
- system("pause");
- }
- #include <iostream>
- using namespace std;
- int main() {
- system("chcp1251");
- double a, b, c, s, p;
- cout << "Wywedete 3 cisla:";
- system("pause");
- }
- #include <iostream>
- using namespace std;
- /*Да се напишат дефинициите на следните функции:
- а) за намиране на средното аритметично на елементите на масив от цели числа;
- б) за намиране на броя на двойките равни съседни елементи в масив от цели числа;
- в) за увеличаване с 12 на всички минимални елементи на масив от цели числа;
- Функциите трябва да могат да работят с масиви с различни дължини */
- // а) за намиране на средното аритметично на елементите на масив от цели числа;
- int CountofMaxRealArray(double anArray[], const int size)
- {
- int count = 0;
- double max = anArray[0];
- for (int i = 1; i < size; i++)
- if (anArray[i] < max)
- max = anArray[i];
- return count;
- }
- // б) за намиране на броя на двойките равни съседни елементи в масив от цели числа;
- int CountOfAdjacentEqual(int anArray[], const int size)
- {
- int count = 0;
- for (int i = 0; i < size - 1; i++) // от първия (0) до предпоследния (size-2)
- if (anArray[i] == anArray[i + 1])
- count++;
- return count;
- }
- // в) за увеличаване с x на всички минимални елементи на масив от цели числа;
- int IncrementMinimalElements(int anArray[], const int size, int x)
- {
- int min = anArray[0];
- for (int i = 1; i < size; i++)
- if (anArray[i] < min)
- min = anArray[i];
- int count = 0;
- for (int i = 0; i < size; i++)
- if (anArray[i] == min)
- {
- anArray[i] = anArray[i] + x;
- count++;
- }
- return count;
- }
- int main()
- {
- int Array[10] = { 1,2,3,4,5,6,7,8,9,10 };
- cout << "a) Average of the array is " << AverageIntArray(Array, 10) << endl;
- int Array2[11] = { 1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8 };
- cout << "b) Count of the adjacent equal elements of the array2 is "
- << CountOfAdjacentEqual(Array2, 11) << endl;
- int Array3[11] = { 3, 2, 4, 3, 2, 4, 2, 6, 7, 2, 8 };
- cout << "c) Count of the minimal elements of the array3 is "
- << IncrementMinimalElements(Array3, 11, 12) << endl;
- for (int i = 0; i < 11; i++) cout << Array3[i] << " ";
- return 0;
- }
- #include<iostream>
- #include <iomanip>
- #include<bitset>
- #include<string>
- using namespace std;
- int main()
- {
- system("chcp 1251");
- int num;
- do {
- cout << "Wywedete cqlo cislo ot 1 do 1000:";
- cin >> num;
- } while (num < 1 || 1000 < num);
- cout << "16-cen zapis:" << hex << num << endl;
- cout << "8-cen zapis:" << oct << num << dec<<endl;
- for (int base = 7; 3 <= base; --base) {
- string str = "";
- int n = num;
- do {
- str = (char)('0' + n % base) + str;
- n /= base;
- } while(n);
- cout <<base<< "-icen zapis:" << bitset<11>(num) << endl;
- }cout << "2-cen zapis:" << bitset<11>(num) << endl;
- system("pause");
- return 0;
- }
- #include<iostream>
- using namespace std;
- #include <string>
- int main()
- {
- system("chcp 1251");
- int s;
- cout << "Enter a whole number bigger than 1:";
- cin >> s;
- string valStr;
- cout << "Enter" << s << "-icen zapis na cqlo cislo:";
- cin >> valStr;
- cout << "10-icna stoinost :" << stoi(valStr, NULL, s) << endl;
- system("pause");
- return 0;
- }
- using System;
- namespace IntroToCSharp
- {
- class HelloCSharp
- {
- static void Main()
- {
- int numberInHex; //declare
- numberInHex = 0x100; // initiliaze
- Console.WriteLine(numberInHex);
- int intValue2 = 0x100;
- Console.WriteLine(intValue2);
- }
- }
- }
- int main() {
- const int n = 20; // брой на оценките double list[n]; // масив с оценки
- // въвеждане на оценките от клавиатурата for(int i=0; i<n; ++i)
- { do{ // въвеждането е с проверка за коректност
- cout << "Evaluation for student No " << i+1 << ": "; cin >> list[i];
- }while(list[i]<2.0 || list[i]>6.0); // само от 2 до 6 }
- // извеждане на списъка с оценки на екрана
- cout << endl << "----- Results -----\n"; c
- out.setf(ios::fixed|ios::showpoint);
- cout.precision(2); for(int i=0; i<n; ++i) cout << "Student No " << i+1 << " - \t" << "evaluation: " << list[i] << endl; cout << endl; return 0; }
- # include <iostream>
- using namespace std;
- int main() {
- system("chcp 1251");
- char ch;
- cout << "Enter znak:";
- cin >> ch;
- if ('a' <= ch && ch <= 'z')
- cout << "Towa e " << ch - 'a' + 1
- << "-a malka latinska bukwa .\n",
- else cout << "Towa ne malka latinska bukwa.\n",
- double x y;
- cout << "Wywedete dwe cisla:";
- cin >> x >> y;
- char rel = x < y ? '<' : x == y
- ? '=' : '>';
- int odd, even;
- do
- cout << "Enter znak:";
- cin >> ch;
- system("pause");
- }
- #include <iostream>
- using namespace std;
- int main()
- {
- cout<<"Hello World";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement