kiem tien, kiem tien online, kiem tien truc tuyen, kiem tien tren mang
Thứ Ba, 24 tháng 3, 2015


Đề bài: nhập vào số nguyên n. Nếu số n là

  • Số chẵn thì tổng S = 2 + 4 + 6 + ... + n
  • Số lẻ thì tổng      S = 1 + 3 + 5 + ....+ n

Bài giải:

#include <stdio.h>

int
main(void){
int
n;
printf("nhap n: ");
scanf("%d",&n);
int
s = 0;
for
(int i=n%2;i<=n;i=i+2)
s+=i;
printf("Tong S = %d",s);
}
24 Mar 2015

0 nhận xét:

Đăng nhận xét

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

domain, domain name, premium domain name for sales

Bài đăng phổ biến