C語言(online c) (寫簡單的程式 請輸入一個數字印出1....n 利用 for , do..loop while )
#include<stdio.h>
#include<math.h>
int main()
{
int x;
printf("請輸入一個數字:\n");
scanf("%d", &x);
printf("你輸入的 N=%d\n",x);
for(int i=1;i<=x;i++)
printf("%d\t",i);
printf("\n");
//===============
int j=1;
while(j<=x)
{
printf("%d\t",j);
j++;
}
printf("\n");
//===============
int k=1;
do{
printf("%d\t",k);
k++;
}while (k<=x);
return 0;
}
Stdin Inputs...
12
請輸入一個數字:
你輸入的 N=12
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11 12
沒有留言:
張貼留言