int+i,+sum+=+0; for+(+i+=+1;+i+<+8;+i+++)+{ +++if+(+i%2+==+0+)+{ +++++++continue; +++} +++sum+=+sum
时间: 2024-01-09 17:23:23 浏览: 164
aula 1_SumSeriesC++_SUM_
根据提供的引用内容,以下是两种不同语言的代码示例:
1. C语言代码示例:
```c
#include<stdio.h>
int main() {
int i;
int sum=0;
for(i=1;i<=4;i++)
sum=sum+i;
printf("sum=%d\n",sum);
return 0;
}
```
2. Java代码示例:
```java
public class Main {
public static void main(String[] args) {
int[] arrayList = new int[20];
int sum = 0;
for(int i=0; i<=19; i++)
arrayList[i] = i+1;
int pos = 0; while(pos<20){
if(arrayList[pos]%2 == 0)
continue;
sum = sum + arrayList[pos];
pos++;
}
System.out.println("sum="+sum);
}
}
```
阅读全文