kiem tien, kiem tien online, kiem tien truc tuyen, kiem tien tren mang
Thứ Hai, 23 tháng 3, 2015



Đề bài: Viết chương trình nhập số nguyên dương n. Tìm số nguyên dương m lớn nhất sao cho: 1 + 2 + 3 + ... + m < n.

Bài giải:

#include <stdio.h>


int
main(){
int
n;
scanf("%d",&n);
int
tong=0;
int
m;
for
(m=1;tong+m<=n;m++){
tong=tong+m;
printf(" %d ", m);
if
(tong+m+1<=n)
printf(" + ");
}

printf(" = %d <= %d\n",tong,n);
printf("\n%d ",m-1);
return
0;
}
23 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