Browsed by
Category: 趣题

一个for语句的趣题

一个for语句的趣题

You should change one character to print “*” 42 times. You can replace, add or remove ONLY one character. Still i cant figured it, i’ve tried over and over again. #include main(){ int i,n = 42; for(i = 0; i < n; i--){ printf("*"); } } Answer 1. 改变循环变量符号。 #include main(){ int i,n = 42; for(i = 0; -i < n; i--){ //added a minus here printf("*"); } } 2. 改变循环条件 #include main(){ int i,n = 42; for(i = 0;...

Read More Read More