1 solutions
-
0
C :
#include <stdio.h> int n, t, i; int main(void) { scanf("%d", &n); for (i = 1; i <= n; i++) { if (!(i % 2)) { t += i; } } printf("%d\n", t); return 0; }C++ :
#include<iostream> using namespace std; int main() { int n,s; cin>>n; s=0; for (int i=1;i<=n;i++) { if (i%2==0) s=s+i; } cout<<s<<endl; return 0; }Pascal :
var a,b,c:longint; begin readln(a); c:=0; for b:=1 to a do if b mod 2=0 then c:=c+b; writeln(c); end.Python :
# coding=utf-8 n = int(input()) t = 0 for i in range(1, n + 1) : if not (i % 2) : t = t + i print(t)
- 1
Information
- ID
- 17745
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By