Определить, как наименьшим числом купюр можно выдать сумму K руб. (K<9999), если есть купюры достоинством 1000 руб., 500 руб., 100 руб., 50 руб. и 10 руб. Оставшуюся мелочь выдать рублями. Условие: решение задачи последовательным делением.
#include <iostream> using std::cout; using std::cin; using std::endl; #include <cstring> using std::strlen;
int main() { char s[100]; char n;
cout << "Enter the string: "; cin.getline(s, 100);
for(int i = 0; i < strlen(s); i++) { if(s[i] == 'a') { n = 'a';
break; } else if(s[i] == 'o') { n = 'o';
break; } }
if(n == 'a') { cout << "\nThe first letter of A" << endl; } else if(n == 'o') { cout << "\nThe first letter of O" << endl; } else cout << "These letters are not available" << endl;
Program project1; uses crt,math; var s:real; i,j,f:real; a:integer; begin writeln('vvedite 1 chislo ');readln(i); writeln('vvedite 2 chislo ');readln(j); writeln('vvedite 3 chislo ');readln(f); s:=i; if j<s then s:=j; if f<s then s:=f; if s<0 then begin if i<0 then inc(a); if j<0 then inc(a); if f<0 then inc(a); writeln('kolichestvo otricatelnix ',a:2); end else begin if i>0 then i:=i*-1; if j>0 then j:=i*-1; if f>0 then f:=i*-1; end; writeln('min chislo ',s:2:0); readln; end.
1)
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
char s[20];
cout << "What is your name: ";
cin >> s;
cout << "Hello, " << s << endl;
return 0;
}
2)
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstring>
using std::strlen;
int main()
{
char s[100];
cout << "Enter the string: ";
cin.getline(s, 100);
for(int i = strlen(s) - 1; i >= 0; i--)
{
cout << s[i];
}
cout << endl;
return 0;
}
3)
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstring>
using std::strlen;
int main()
{
char s[20];
bool x = true;
cout << "Enter the word: ";
cin.getline(s, 100);
for(int i = 0, j = strlen(s) - 1; i <= j; i++, j--)
{
if(s[i] != s[j])
{
x = false;
break;
}
}
if(x)
{
cout << "Palindrome" << endl;
}
else
cout << "Not palindrome" << endl;
return 0;
}
4)
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstring>
using std::strlen;
int main()
{
char s[100];
char n;
cout << "Enter the string: ";
cin.getline(s, 100);
for(int i = 0; i < strlen(s); i++)
{
if(s[i] == 'a')
{
n = 'a';
break;
}
else if(s[i] == 'o')
{
n = 'o';
break;
}
}
if(n == 'a')
{
cout << "\nThe first letter of A" << endl;
}
else if(n == 'o')
{
cout << "\nThe first letter of O" << endl;
}
else
cout << "These letters are not available" << endl;
return 0;
}
uses
crt,math;
var s:real; i,j,f:real; a:integer;
begin
writeln('vvedite 1 chislo ');readln(i);
writeln('vvedite 2 chislo ');readln(j);
writeln('vvedite 3 chislo ');readln(f);
s:=i;
if j<s then s:=j;
if f<s then s:=f;
if s<0 then
begin
if i<0 then inc(a);
if j<0 then inc(a);
if f<0 then inc(a);
writeln('kolichestvo otricatelnix ',a:2);
end
else
begin
if i>0 then i:=i*-1;
if j>0 then j:=i*-1;
if f>0 then f:=i*-1;
end;
writeln('min chislo ',s:2:0);
readln;
end.