Advertisement
toan9xpro2012

Cap so cong

Feb 10th, 2017
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.44 KB | None | 0 0
  1. program cau1;
  2. uses crt;
  3. var n,i,w:integer;
  4.     congsai:real;
  5.     a:array[1..100] of real;
  6.  
  7. begin
  8.  clrscr;
  9.  write('Nhap n= ');readln(n);
  10.  for i:=1 to n do
  11.   begin
  12.    write('a[',i,']= ');
  13.    readln(a[i]);
  14.   end;
  15.   congsai:=a[2]-a[1];
  16.   w:=0;
  17.  for i:=1 to n do
  18.    if (a[i] <> a[1]+(i-1)*congsai) then inc(w);
  19.  if w<>0 then
  20.   write('Day da nhap khong phai cap so cong')
  21.  else
  22.   write('Day da nhap la cap so cong');
  23.  readln;
  24. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement