百度知道 理工学科 添加到搜藏 待解决 帮忙看下这道题为什么RE
百度知道 > 理工学科 添加到搜藏 待解决 帮忙看下这道题为什么RE百度知道 > 理工学科 添加到搜藏 待解决 帮忙看下这道题为什么RE 代码 #include <iostream> #include <cstdlib> #include <vector> #include <cstring> #include <cmath> #include <string> using namespace std; void ltoi( string &str ,int &x,int &num); int numlen( char *cstr ); const double LIMIT=0.000001; int main(){ int a = 0; int line; cin >> line; while( a < line && line <=10 && line >= 1 ){ int n; int len; string str; double ans = 0; vector<int> num; vector<int> x; int num_t = 0 ,x_t = 0; cin >> str; while( str[ 0 ] != '=' ){ int x1 = 0 ,num1 = 0; ltoi(str,x1,num1); if( x1 ) x.push_back(-x1); if( num1 ) num.push_back(-num1); if( str[ 0 ] =='+' ) str = bstr(1); } str = bstr(1); while( str[ 0 ] ){ int x1 = 0 ,num1 = 0; ltoi(str,x1,num1); if( x1 ) x.push_back(x1); if( num1 ) num.push_back(num1); if( str[ 0 ] =='+' ) str = bstr(1); } for( int i = 0 ;i < ze(); i++ ) x_t += x[ i ]; for( int i = 0 ;i < ze(); i++ ) num_t += num[ i ]; if( x_t == 0 ){ if( num_t== 0 ) cout << "IDENTITY"; else cout << "IMPOSSIBLE"; } else{ ans = -num_t/x_t; if(fabs(ans)<LIMIT) cout << 0; else if(ans > 0) cout << floor(ans); else if(ans < 0) cout << floor(ans)-1; } cout << endl; } return 0; } void ltoi( string &str ,int &x,int &num){ int n,len; char str1[260]; if( str[ 0 ] == 'x' ){ n = 1; str = bstr(1); x = 1; } else if( str[ 0 ] == '-' && str[ 1 ] == 'x' ){ n = -1; str = bstr(2); x = -1; } else{ n = atoi(str.c_str()); sprintf(str1,"%d",n); len = numlen(str1); if( str[ len ] == 'x' ){ x = n; str = bstr(len+1); } else{ num = n; str = bstr(len); } } } int numlen( char *cstr ){ int i; for( i = 0 ;cstr[ i ] ; i++ ); return i; }
请把问题写清楚,写完整,大家才能帮你解答
你要问什么?
答:二、多项选择题(共10题) 1.下列各项中,体现实质重于形式要求的有(ABCD )。 A.将融资租赁的固定资产作为自有固定资产入账 B.合并会计报表的编制 C...详情>>
问:挺简单的一C函数,不过我是初学者,暂时还不会写,请好心人多多帮忙!
答:int mystrlen(char *str) { int n = 0; while (*str) { n++; str++;} return n; } voi...详情>>