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 a[1000],n,i,x;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
cin>>x;
bool kt=false;
for (i=1; i<=n; i++)
if (a[i]==x)
{
cout<<i;
break;
kt=true;
}
if (kt==false) cout<<"Khong co";
return 0;
}
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,x,dem,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap x='); readln(x);
kt:=0;
dem:=0;
for i:=1 to n do
if a[i]=x then
begin
kt:=1;
write(i:4);
inc(dem);
end;
if kt=0 then writeln('Khong co ',x,' trong day');
writeln(x,' xuat hien ',dem,' lan trong day');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) t+=a[i];
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[100],i,n,t,x,k;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
t=0;
for (i=1;i<=n; i++)
if (a[i]>0) t+=a[i];
cout<<t<<endl;
cin>>x>>k;
a[0]=x;
sort(a[k],a[0]);
for (i=0; i<=n; i++)
cout<<a[i]<<" ";
cout<<endl;
for (i=0; i<=n; i++)
if (a[i]<=0) cout<<a[i]<<" ";
return 0;
}
Bài 1
Var s,i:integer;
tb:real;
Begin
Write('Nhap n = ');readln(n);
i:=1;
s:=0;
While i<=n do
Begin
s:=s+i;
i:=i+1;
End;
tb:=s/n;
Writeln('Tong la ',s);
Write('Trung binh la ',tb:10:2);
Readln;
End.
Bài 2
Var i,n,souoc:integer;
Begin
Write('Nhap n = ');readln(n);
i:=1;
While i <= n do
Begin
i:=i + 1;
If n mod i = 0 then souoc:=souoc + 1;
End;
If souoc = 1 then write(n,' la so nguyen to')
Else write(n,' khong la so nguyen to');
Readln;
End.
#include <bits/stdc++.h>
using namespace std;
int main ()
{
int a[32];
int n,i,s;
cout<<"nhap so phan tu cua mang ";
cin>>n;
cout<<"nhap cac phan tu cua mang ";
for (i=1; i<=n; i++)
{
s=0;
cin>>a[i];
}
for(i=1; i<=a[i]; i++) s=s+i;
cout<<s;
return 0;
}
program dem_so;
uses crt;
var i,n,dem,k:longint;
a:array[1..100]of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write(a[',i,']=');readln(a[i]);
end;
dem:=0;
write('nhap so k:');readln(k);
for i:=1 to n do
if a[i]=k then dem:=dem+1;
if dem=0 then write(k,' khong co trong day so tren');
readln;
end.
Ai giải giúp mik ạ