/*
Ví dụ1:
In ra man hinh tat ca so nguyen co 3 chu so sao cho tong cua chung bang 10
*/
#include<iostream.h>
#include<conio.h>
void main(){
cout<<"\n In ket qua: \n ";
for (int i=100;i<=999;i++)
if(i%10+(i/10)%10+(i/100)%10==10)
cout<<i<<"; ";
getch();
}
//--------------------------------
/*
Ví dụ 2:
Tính tổng
s=x+2x^2 +3x^3 +... + nx^n
(x, n nhap vao tu ban phim, thoa man
1<=x<=3; 1<=n<=10)
*/
#include<iostream.h>
#include<math.h>
#include<conio.h>
void main(){
int n;
float x;
// nhap n
do{
cout<<"\n n=";
cin>>n;
if(n<1||n>10)
cout<<"\n Nhap lai n!";
}while(n<1||n>10);
// nhap x
do{
cout<<"\n x=";
cin>>x;
if(x<1||x>3)
cout<<"\n Nhap lai x!";
}while(x<1||x>3);
// tinh s
float s=0;
int i=1;
while(i<=n)
{
s=s+i*(float)pow(x,i); // x^i
i++;
i++;
}
cout<<"\n S= "<<s;
getch();
}