[已解决]是因为string 的问题吗?(c语言中) 大家帮忙看看。
发表于 : 2009-05-07 18:07
#include <stdio.h>
#include <stdlib.h>
/*
*
*/
string PriScore( int score[]);
int GetScore(int score[]);
int main(int argc, char** argv)
{
int m;
int scorearray[m];
m = 100;
GetScore(scorearray);
PriScore(scorearray);
return (EXIT_SUCCESS);
}
int GetScore(int score[])
{
int n,value;
while(1)
{
scanf("%d ",&value);
score[n] = value;
if( value == 101) break;
n++;
}
return n;
}
string PriScore(int score[])
{
int i, j, k;
int count[11];
string scores[]={
"0-9 |", "10-19 |", "20-29 |", "30-39 |", "40-49 |",
"50-59 |", "60-69 |", "70-79 |", "80-89 |", "90-99 |",
"100 |",};
for(i = 0; i<= 10; i++)
{
if(score/10 == i)
{
count++;
}
}
for(j = 0; j <= 10; j++)
{
if(count[j] == 0)
{
printf("%s\n ",scores[j]);
} else
{
printf("%s ",scores[j]);
for(k = 0; k < count[j]; k++)
{
printf("*");
}
printf("\n");
}
}
return(EXIT_SUCCESS);
}
运行结果 提示: (上面 下划线和红色的行就是:18 30 48 行)
styloliticchart.c:18: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PriScore’
styloliticchart.c: 在函数‘main’中:
styloliticchart.c:30: 警告: 隐式声明函数‘PriScore’
styloliticchart.c: 在文件层:
styloliticchart.c:48: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PriScore’
#include <stdlib.h>
/*
*
*/
string PriScore( int score[]);
int GetScore(int score[]);
int main(int argc, char** argv)
{
int m;
int scorearray[m];
m = 100;
GetScore(scorearray);
PriScore(scorearray);
return (EXIT_SUCCESS);
}
int GetScore(int score[])
{
int n,value;
while(1)
{
scanf("%d ",&value);
score[n] = value;
if( value == 101) break;
n++;
}
return n;
}
string PriScore(int score[])
{
int i, j, k;
int count[11];
string scores[]={
"0-9 |", "10-19 |", "20-29 |", "30-39 |", "40-49 |",
"50-59 |", "60-69 |", "70-79 |", "80-89 |", "90-99 |",
"100 |",};
for(i = 0; i<= 10; i++)
{
if(score/10 == i)
{
count++;
}
}
for(j = 0; j <= 10; j++)
{
if(count[j] == 0)
{
printf("%s\n ",scores[j]);
} else
{
printf("%s ",scores[j]);
for(k = 0; k < count[j]; k++)
{
printf("*");
}
printf("\n");
}
}
return(EXIT_SUCCESS);
}
运行结果 提示: (上面 下划线和红色的行就是:18 30 48 行)
styloliticchart.c:18: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PriScore’
styloliticchart.c: 在函数‘main’中:
styloliticchart.c:30: 警告: 隐式声明函数‘PriScore’
styloliticchart.c: 在文件层:
styloliticchart.c:48: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PriScore’