2014-01-25 119 views
-3

即時嘗試打印隨機值的10x4表格。即時通訊新的C,但仍然不真正unsendtand如何嵌套在c循環。即時猜測theres錯誤與一個花括號某處,但imn不知道。任何幫助?輸入結束時的預期聲明或聲明C

#include <stdio.h> 
#include <stdlib.h> 

int main(void) 
{ 
    int row = 0, column = 0 ; 
    while (column < 11) 
    { 
     row = 1; 
     while (row < 5) 
     { 
      printf ("%lf", random()); 
      row = row + 1; 
    } 
    column = column + 1; 

} 

錯誤說,這是在最後一行

+4

算括號的數量('{'和'}')。 –

+4

我想你正確地格式化你的代碼,然後這種錯誤就會跳出你。 –

+0

您的代碼副本的縮進更正(並且沒有其他更改)如下:http://pastebin.com/JVEVTBBp。在其他問題中,'{'在'row = 1;'後面放錯了位置;它應該在'while'之後。 –

回答

2

變化

row = 1; 
{ 
    while (row < 5) 
     printf ("%f", random()); 
     row = row + 1; 
} 
column = column + 1; 

row = 1; 
    while (row < 5) 
    { 
     printf ("%f", random()); 
     row = row + 1; 
    } 
    column = column + 1; 
} 
+0

'random()'返回一個雙精度值,'printf'用於帶有「%f」'的浮點數,它需要對'「%d」'進行修正。 – user2485710

+1

@ user2485710''%d「'格式爲decimal *整數*。對於雙打,格式爲「%lf」。 –

+0

@JoachimPileborg腦屁,對不起... – user2485710