24小时热门版块排行榜    

CyRhmU.jpeg
查看: 412  |  回复: 1

xiaowu787

木虫 (正式写手)

[求助] 解读一个子程序的意思

自己对程序了解的少,不明白这个子程序(Please input the extensions in x, y, and z directions运行后需要输入什么?顺便请大家帮忙解读一下这个子程序的意思,谢谢
CODE:
void Driver::generate()
{
  char str[MAXLINE];
  int leading_dir = 1;
  printf("\n"); for (int i=0; i<70; i++) printf("="); printf("\n");
  while (1){
    printf("Please input the extensions in x, y, and z directions: ");
    if (count_words(fgets(str,MAXLINE,stdin)) < 3) continue;
    nx = atoi(strtok(str,  " \t\n\r\f"));
    ny = atoi(strtok(NULL, " \t\n\r\f"));
    nz = atoi(strtok(NULL, " \t\n\r\f"));
    natom = nx*ny*nz*latt->nucell;
    if (natom > 0) break;
  }

[ Last edited by xiaowu787 on 2012-3-21 at 09:56 ]
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

lurencyj

木虫 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
jjdg: 金币+1, 感谢参与 2012-03-22 00:34:52
xiaowu787: 金币+15, ★★★★★最佳答案, 谢谢 2012-03-23 08:55:32
strtok是字符串分割函数。
你输入三个整数,用回车或者table键盘相互分开,就好。

第一个是nx, 第二个是ny, 第三个是nz
很女子很弓虽大
2楼2012-03-21 19:30:13
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 xiaowu787 的主题更新
信息提示
请填处理意见