Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************************/
- /** 20140325 Basic Print Star Example **/
- /** Maker : Yan **/
- /** E-Mail : [email protected] **/
- /** Date : 2014/03/25 am.10:18 **/
- /****************************************/
- #include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- //建立變數input, 此為輸入數值
- int input = 0;
- /*for 之無窮迴圈使用方式為
- for( ; ; ),相同於while(1)*/
- for( ; ; )
- {
- printf("Input a number: ");
- //輸入數值
- scanf("%d", &input);
- //當input 為1 時跳出迴圈(break = 跳出迴圈)
- if(input == -1){break;}
- //執行迴圈輸出星號
- for(int i = 1; i <= input; i++)
- {
- printf("*");
- }
- //斷行
- printf("\n");
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment