99table
How to use R write 9*9 table
R code
for(i in seq(2,9,by=1)){
for(j in 1:9){
cat(i,"*",j,"=",i*j,"\n")
}}
Cpp
#include
using namespace std;
int main() {
for(int j = 1; j < 10; j++) {
for(int i = 2; i < 10; i++) {
int tmp = i * j;
cout << i << "*" << j;
if(tmp >= 10)
cout << "=" << tmp;
else
cout << "= " << tmp;
cout << " ";
}
cout << endl;
}
system("PAUSE");
return 0;
}
#################################
#include
using namespace std;
int main() {
for (int i = 2, j = 1;
j < 10;
(i==9)?(i=(++j/j)+1):(i++)) {
int tmp = i * j;
cout << i << "*" << j;
cout << ((tmp>=10)? "=": "= ") ;
if(i == 9)
cout << i*j << endl;
else
cout << i*j << " ";
}
system("PAUSE");
return 0;
}
沒有留言:
張貼留言