https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
char c
while(cin>>c){
cout<<c;
}
這樣嗎?
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
char c
while(cin>>c){
cout<<c;
}
這樣嗎?
類似,
但cin會吃掉'\n'和' '。
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
char c
while(cin>>c){
cout<<c;
}
這樣嗎?
類似,
但cin會吃掉'\n'和' '。
#include<iostream>
using namespace std;
int main(){
char c;
while(cin.get(c)){
cout<<c;
}
}
這樣
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
char c
while(cin>>c){
cout<<c;
}
這樣嗎?
類似,
但cin會吃掉'\n'和' '。
#include
using namespace std;
int main(){
char c;
while(cin.get(c)){
cout<<c;
}
}
這樣
謝學長,但這算cin嗎?
還有scanf呢?
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
char c
while(cin>>c){
cout<<c;
}
這樣嗎?
類似,
但cin會吃掉'\n'和' '。
#include
using namespace std;
int main(){
char c;
while(cin.get(c)){
cout<<c;
}
}
這樣
謝學長,但這算cin嗎?
還有scanf呢?
應該算,但不知道會不會對他的速度造成影響
你要做的測試數據應該都在這裡(這網站算是大網站,數據會比較可靠):https://www.irjet.net/archives/V3/i7/IRJET-V3I7326.pdf
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
char c
while(cin>>c){
cout<<c;
}
這樣嗎?
類似,
但cin會吃掉'\n'和' '。
#include
using namespace std;
int main(){
char c;
while(cin.get(c)){
cout<<c;
}
}
這樣
謝學長,但這算cin嗎?
還有scanf呢?
應該算,但不知道會不會對他的速度造成影響
你要做的測試數據應該都在這裡(這網站算是大網站,數據會比較可靠):https://www.irjet.net/archives/V3/i7/IRJET-V3I7326.pdf
喔~~~完全看不懂......
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
char c
while(cin>>c){
cout<<c;
}
這樣嗎?
類似,
但cin會吃掉'\n'和' '。
#include
using namespace std;
int main(){
char c;
while(cin.get(c)){
cout<<c;
}
}
這樣
謝學長,但這算cin嗎?
還有scanf呢?
應該算,但不知道會不會對他的速度造成影響
你要做的測試數據應該都在這裡(這網站算是大網站,數據會比較可靠):https://www.irjet.net/archives/V3/i7/IRJET-V3I7326.pdf
喔~~~完全看不懂......
這我幫不了你.....你就看表格的數據就好
https://taurenprogram.blogspot.com/2019/04/coutprintf-part5.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part4.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part3.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part2.html
https://taurenprogram.blogspot.com/2019/04/coutprintf-part1-c-include-using.html
為甚麼我自己測試cout加ios::sync_with_stdio(false)會比printf快這麼多?
跟網路上完全不一樣?
大大們告訴小弟我做錯甚麼吧!
我把數字加大到10^6
結果十分令人驚訝...
1~10^6 int (array) (output size: 6888864 bytes , 6.569 MB):
cout+sync off+'\n':27.04 s (1st)
cout+endl :232.1 s (2nd)
cout+'\n' :269.1 s (3rd)
printf :418.1 s (4th)
10^6 string ("Hello world") (output size: 12000000 bytes , 11.444 MB):
cout+sync off+'\n':20.08 s (1st)
puts :98.53 s (2nd)
cout+'\n' :143.8 s (3rd)
cout+endl :238.4 s (4th)
printf :677.5 s (5th)
putchar :691.3 s (6th)
10^6 (int(1~10^6)+string(". Hello world"))(output size: 20888864 bytes , 19.921 MB):
cout+sync off+'\n':14.56 s (1st)
cout+'\n' :219.0 s (2nd)
cout+endl :273.5 s (3rd)
printf :956.6 s (4th)
1~10^6 double(precision:3) (output size: 10888864 bytes , 10.384 MB):
cout+sync off+'\n':16.87 s (1st)
cout+endl :140.3 s (2nd)
cout+'\n' :188.5 s (3rd)
printf :549.5 s (4th)
1.看的出來我的電腦很慢XD
2.printf真的好慢
printf慢的原因,應該是因為他是格式化輸出,可是還是與本人的經驗相違背
那就代表~~~~~
cin,cout簡單又好用XD
還有我的測試沒錯XD
1.你測的只有cout和printf,cin和scanf可沒測
2.我用a007的建表法實測:
cin/cout : 1s
scanf/printf : 0.8s
scanf/puts : 0.7s
cin/cout(ios::sync_with_stdio(0);cin.tie(0);) : 0.7s
所以我說實驗結果與我的經驗相違背
我又做了一個測試:
探討cin與scanf的差別 (一)速度 part1:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part1.html
我還在繼續製作相關的測試
我問一下cin要怎麼讀' '和'\n'?
是指怎麼讀一整行嗎?
不,而是:
輸入:
1
1
1
1
1
輸出:
1
1
1
1
1
(一樣的東西)
(只能用cin,cout)
這可以當良心題了ㄟXD
char c
while(cin>>c){
cout<<c;
}
這樣嗎?
類似,
但cin會吃掉'\n'和' '。
#include
using namespace std;
int main(){
char c;
while(cin.get(c)){
cout<<c;
}
}
這樣
謝學長,但這算cin嗎?
還有scanf呢?
應該算,但不知道會不會對他的速度造成影響
你要做的測試數據應該都在這裡(這網站算是大網站,數據會比較可靠):https://www.irjet.net/archives/V3/i7/IRJET-V3I7326.pdf
喔~~~完全看不懂......
這我幫不了你.....你就看表格的數據就好
探討cin與scanf的差別 (二)速度 part2:
https://taurenprogram.blogspot.com/2019/04/cinscanf-part2.html
我測過cin和cin.get()了
10000000個1,cin.get()平均比cin快0.1左右(不加速)