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;
long long n,i,a[10000];
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
Câu 4:
#include <bits/stdc++.h>
using namespace std;
string st;
int d,i,dem;
char x;
int main()
{
getline(cin,st);
d=st.length();
cout<<st<<endl;
cin>>x;
dem=0;
for (i=0; i<=d-1; i++) if (st[i]==x) dem++;
cout<<dem;
return 0;
}
Câu 4:
#include <bits/stdc++.h>
using namespace std;
string st;
int d,i,dem;
char x;
int main()
{
getline(cin,st);
d=st.length();
cout<<st<<endl;
cin>>x;
dem=0;
for (i=0; i<=d-1; i++) if (st[i]==x) dem++;
cout<<dem;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
Program HOC24;
var i.n: integer;
a: array[1..250] of integer;
begin
for i:=1 to n do
begin
write('Nhap diem toan cua ban thu ',i,': '); readln(a[i]);
end;
for i:=1 to n do write(a[i],' ');
readln
end.
Program HOC24;
var m,i,d: integer;
a: array[1..32000] of integer;
begin
write('Nhap m= '); readln(m);
for i:=1 to m do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap X = '); readln(x);
d:=0;
for i:=1 to n do if a[i]=x then d:=d+1;
write(X,' xuat hien ',d,' lan trong mang');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,kt,max,x,j,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Mang ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('Day tang dan la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
write('Nhap x='); readln(x);
max:=0;
kt:=0;
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]<=x) then
begin
if max<a[i] then max:=a[i];
kt:=1;
end;
if kt=0 then writeln('Trong day khong co so le')
else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
uses crt;
var a:array[1..50]of integer;
m,n,t,min,vt:integer;
begin
clrscr;
write('Nhap m='); readln(m);
for i:=1 to m do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to m do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to m do
t:=t+a[i];
writeln('Tong cac phan tu la: ',t);
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
vt:=0;
for i:=1 to n do
if min=a[i] then inc(vt);
writeln('So nho nhat la: ',min);
writeln('So lan xuat hien la: ',vt);
readln;
end.