#include<stdio.h> #include<math.h> #include<string.h> int main() { char s[100]; int i; while(gets(s) != NULL) { if(strcmp(s,"0") == 0) break; int a[3] = {0},k = 0; for(i = 0;s[i];i++) { if(s[i] != ' ') a[k] = a[k]*10 + s[i]-'0'; else k++; } if(a[1] == 0) { for(i = 1;i <= a[0];i++) printf("%d%c",i,i==a[0]?'\n':' '); } else { if(a[0] > a[1]) { for(i = a[0];i >= a[1];i = i - a[2] - 1) { if(i == a[0]) printf("%d",i); else printf(" %d",i); } putchar(10); } else { for(i = a[0];i <= a[1];i+=a[2]+1) { if(i == a[0]) printf("%d",i); else printf(" %d",i); } putchar(10); } } } return 0; } |
Double click to view unformatted code.