Viết chương trình cho phép chỉ nhập đúng 10 số lẻ bất kỳ.
Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, f, g, h, i, j;
cin >> a >> b >> c >> d >> e >> f >> g >> h >> i >> j;
if(a%2==0)
cout << "Vui long thu lai" << endl;
else if(b%2==0)
cout << "Vui long thu lai" << endl;
else if(c%2==0)
cout << "Vui long thu lai" << endl;
else if(c%2==0)
cout << "Vui long thu lai" << endl;
else if(d%2==0)
cout << "Vui long thu lai" << endl;
else if(e%2==0)
cout << "Vui long thu lai" << endl;
else if(f%2==0)
cout << "Vui long thu lai" << endl;
else if(g%2==0)
cout << "Vui long thu lai" << endl;
else if(h%2==0)
cout << "Vui long thu lai" << endl;
else if(i%2==0)
cout << "Vui long thu lai" << endl;
else if(j%2==0)
cout << "Vui long thu lai" << endl;
else
cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << " " << j << endl;
return 0;
}
Chúc bn học tốt! (Mk định dùng kiểu mảnh nhưng nó bị lỗi nên mk dùng cách này, nó hơi dài mong bn thông cảm!)
#include <bits/stdc++.h>
using namespace std;
long long m,n,i;
int main()
{
cin>>m>>n;
for (i=m; i<=n; i++)
if (i%2==1) cout<<i<<" ";
return 0;
}
program vdd;
uses crt;
var i,n: integer;
begin
clrscr;
write('Nhap N: '); readln(n);
for i:=1 to n do if i mod 2=1 then write(i,';');
readln
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i]<0 then write(a[i]:4);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i]>0 then write(a[i]:4);
readln;
end.
TK:
uses crt;
var n: longint;
begin
clrscr;
readln(n);
if n mod 2 = 0 then writeln('Chan') else writeln('Le');
readln;
end.
#include<bits/stdc++.h>
using namespace std;
long long N;
int main()
{
cin>>N;
if(N%2==0) cout<<N<<" là số chẵn";
if(N%2!=0) cout<<N<<" là số lẻ";
}
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<a*b<<endl;
cout<<fixed<<setprecision(2)<<(a*1.0)/(b*1.0);
return 0;
}
Câu 1 viết chương trình nhập vào 1 dãy n số nguyên bất kỳ .In ra màn hình tổng các số chia hết cho 2
uses crt;
var i,n:integer;
t:longint;
a:array[1..100]of integer;
begin
clrscr;
write('nhap n:');readln(n);
t:=0;
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
if a[i] mod 2=0 then t:=t+a[i];
end;
write(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int i,a;
for (i=1; i<=10; i++)
{
do
{
cin>>a;
if (a%2==0) cout<<"Nhap lai";
} while (a%2!=0);
}
return 0;
}