C语言作业:while

27 阅读1分钟
#include <stdio.h>

int main() {
    int s = 0;    
    int i = 1;    
    while (i <= 99) {
        s += i;   
        i += 2;   
    }
    printf("%d\n", s);
    return 0;
}

image.png

#include <stdio.h>

int main() {
    int s = 0;    
    int i = 2;    
    while (i <= 100) {
        s += i;   
        i += 2;   
    }
    printf("作业2的结果:s = %d\n", s);
    return 0;
}

image.png