| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 455 人关注过本帖
标题:调用函数输入与输出
只看楼主 加入收藏
slightt
Rank: 1
来 自:惠州
等 级:新手上路
帖 子:24
专家分:0
注 册:2010-4-11
结帖率:100%
收藏
 问题点数:0 回复次数:3 
调用函数输入与输出
这个函数可运行,但实际操作时却出问题,什么原因?
 有空热心人士请帮个忙!
 #include "Stdio.h"
char st[6][15];
 float cj[6][4];

 main()
 {  void input();
    void output();
    input();
    output();
    getch();
 }

 void input( )
 {
    int i,j;
    for(i=1;i<6;i++)
    {
       printf("input the %dth name and score:\n",i);
       scanf("%s",st[i]);
       for(j=1;j<4;j++)
          scanf("%f",&cj[i][j]);
    }
  }



  void output()
  {  int i,j;
     printf("the students' scores show as follows:\n");
     for(i=1;i<6;i++)
       { printf("%8s",st[i]);
         for(j=1;j<4;j++)
            printf("%7.2f",cj[i][j]);

         printf("\n");
       }
  }
搜索更多相关主题的帖子: 函数 输出 输入 
2010-04-17 13:37
雨夜星光
Rank: 4
等 级:业余侠客
帖 子:66
专家分:230
注 册:2009-11-25
收藏
得分:0 
#include "Stdio.h"
char st[6][15];
float cj[6][4];

main()
{  void input();
    void output();
    input();
    output();
    getchar();
}

void input( )
{
    int i,j;
    for(i=0;i<6;i++)
    {
       printf("input the %dth name and score:\n",i+1);
       scanf("%s",st[i]);
       for(j=0;j<4;j++)
          scanf("%f",&cj[i][j]);
    }
  }



  void output()
  {  int i,j;
     printf("the students' scores show as follows:\n");
     for(i=0;i<6;i++)
       { printf("%8s",st[i]);
         for(j=0;j<4;j++)
            printf("%7.2f",cj[i][j]);

         printf("\n");
       }
  }

没有做多大改动,自己对比一下吧!注意这个问题就行了:数组的第一个数是从下标0开始的

C/C++交流群:65802335
2010-04-17 20:04
草狼
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:2
帖 子:577
专家分:1040
注 册:2010-4-6
收藏
得分:0 
input the 1th name and score:
a 1 2 3
input the 2th name and score:
b 1 2 3
input the 3th name and score:
c 1 2 3
input the 4th name and score:
d 1 2 3
input the 5th name and score:
e 1 2 3
the students' scores show as follows:
       a   1.00   2.00   3.00
       b   1.00   2.00   3.00
       c   1.00   2.00   3.00
       d   1.00   2.00   3.00
       e   1.00   2.00   3.00

程序代码运行没错啊
2010-04-17 20:51
slightt
Rank: 1
来 自:惠州
等 级:新手上路
帖 子:24
专家分:0
注 册:2010-4-11
收藏
得分:0 
回复 2楼 雨夜星光
数组是可以手动设为1开始的
2010-04-18 22:13
快速回复:调用函数输入与输出
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014784 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved