[英]Attempting to remove repeated 0 on c program
我有一個C程序,在您鍵入-1之前,您會引入一個數字序列,它可以與gcc的debian編譯(“ $ gcc act.c -o act”)配合使用,但是現在我在Windows 10上使用devc ++和TDM- GCC 4.9.2,輸出失敗
如果引入“ 1 5 6 7 8 0 0 0 0 5 5 6 6 6 6 8 4 1 0 0 0 2 5 0 5 6 8”,則輸出必須為“ 1 5 6 7 8 0 5 5 6 6 6 6 8” 4 1 0 2 5 0 5 6 8“
正如我在linux上工作時所說的,但在Windows上,在這種情況下,輸出只是第一個數字。
我的代碼有什么問題?
碼:
#include <stdio.h>
int main(){
int secuencia_numeros;
int aux_secuencia_numeros = -1; //Utilizamos el -1 como numero auxiliar
printf("\n\n\t Quitar ceros consecutivos.\n\n");
printf("Introduce una secuencia de numeros [fin = -1]: ");
scanf("%d",&secuencia_numeros);
while(secuencia_numeros != -1) {
fflush( stdin );
if((secuencia_numeros ==0)&&(aux_secuencia_numeros == 0)) {
}else{
printf("%d ",secuencia_numeros);
}
aux_secuencia_numeros = secuencia_numeros;
scanf("%d",&secuencia_numeros);
}
printf("\n");
return 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.