请问大神f2有没有电信版C++大神给我一个挖地雷的C++代码?

求一c++大神看下我的代码哪错了_百度知道
求一c++大神看下我的代码哪错了
太长发不上来
请大神加我细聊
分不会少的
提问者采纳
提问者评价
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁求大神给我编一个C++程序,谢谢了,问题在问题补充里面,不胜感激涕零!!!呜呜!!!_百度知道
求大神给我编一个C++程序,谢谢了,问题在问题补充里面,不胜感激涕零!!!呜呜!!!
平均分),以及最高和最低的平均分的学生姓名、3门课的成绩、3门课的平均分、3门课的成绩,每个学生的数据包括学号、姓名,要求打印出学生的相关信息(学号、姓名,并从键盘输入10个学生的数据有10个学生
提问者采纳
&nbsp,name(name);&&&&&&&&&&&&&&&nbsp#include&&&&&ite=&&&&&&&get_name()&}&&&&get_name()&&&&&&&&&vector&highest=&++n)&data&&&&&&n+1&total+=*ite-&&&name&quot。学生人数和课程数目可以根据需要修改;&&&&using&&&&&endl:iterator&&nbsp,course);cout&&nbsp.begin();&&&&&&&&&&string&&d(&&&get_grade(num)&n=0;}&&&{&&&&&&&{&&&&&&&highest=&;&&cout&&get_average())&&&grade&string&iostream&average=total/&&&ite-&&'}&&&&is&&&&&&nbsp:iterator&nbsp.end();&&&&course[num];&&enter&&&{&nbsp!=&&&&&&student&&cout&namespace&nbsp,代码的扩展性和维护性较好;&return&&&&&&&&{&&&&&&&&&&&&&get_average())&string&&int&int&&&{&&&&&&nbsp:iterator&nbsp.size();&nbsp.insert(&num=0;&&lt:;&get_id()&&&&&&&&&&data&&&nbsp.begin();&num_of_&class&&&&&lowest=&}};&&&&&};&&&&&&&&id(id);&&student&&&&get_average()&for(int&get_average()&&&#include&&&&&&int&&average&&c++.0;&&&&&&data(int&&&&&for(int&&ite++)&n&lt.end();&&&cin&&;&&&&&&lowest&&&vector&&cout&&&&&&const&&nbsp,grade);ite-&&&&&&&grade:&data{&for(vector&&&&&&&&&&&&&&cout&&ite-&&get_name()&num)&;&&data&&&&&&}&get_average()&&&if(lowest-&for(int&&&&ite-&get_average()&&&nbsp:;name&for&nbsp:&&}&{&endl&i&&&&&&nbsp:iterator&&cout&cout&&vector&&&&&&id&&&nbsp.insert(db.end();&&&&&&&const&&is&&&&course&double&&int&course&&&enter&&nbsp:;vector&&&enter&&&&data&&&int&&&&&&string&&}&&&cin&&&&&&&&lowest=&&&cout&&&&&&&&cin&course);&&endl,name.end();&&&&;int&int&&++num)&&nbsp,course(course){&int&&&average&&&&#include&&&&&&&&&&&&student&&&&vector&grade&&&int&&int&&return&i=0;&&&&&&&&&&&num+1&&nbsp,vector&&&&&num&int&&&&&&&&is&nbsp:&double&with&&&&&}&&&&&is&&&&&&&&&&&&&&&&for(vector&&&&&lt,d);&&get_name()&&&&&num_of_&&&&&&&&&vector&total=0;;&the&&nbsp:&if(highest-&&&data&&&get_id()&num_of_courses=3;++i)&&&&nbsp:;course&&&&;return&&&&num_of_students=2;&ite++)&&&{&&&&&&&&double&&&s&}&&&&&main(){&num_of_courses.begin();lowest-&&&&{&ite-&avarage&&&&ite=&nbsp!=with&&&&&&highest&&&return&&&&int&get_grade(int&&&student&&&&&&highest-&gt,string&nbsp.begin();cout&lt
有10个学生啊 这个程序怎么只能计算2个学生的成绩啊?
啊,我测试的时候用的是两个,把第42行的num_of_students 改成 10 就好了
行了 不过我想把这个程序优化一下 将三门课程分别改为数学、物理、理论力学,这样输出的时候就比较清晰了,该怎么改啊?
添加了一个类,这样课程数目不限于3们,可维护性和可扩展性良好,超字数了,我放附件了。
额 我下载了以后 直接复制粘贴到那里面怎么不行啊 说什么行将超过多少个字什么的 就是粘贴不进去 请问这是怎么回事啊?谢谢!
用的什么垃圾软件啊?
还没弄好么?能智慧一点么
额。。。请大侠明示
复制粘贴不行,你对比一下看看哪里不一样了改过来就是了
大神 你在了啊
我有个程序 帮忙改一下吧 谢谢啦!等了好几天了
提问者评价
呜呜呜呜呜呜~~~~~~~
其他类似问题
按默认排序
其他2条回答
不会,如果不满意答案在另寻吧,也可以实现这个功能,在EXCEL电子表格,不过给你个凑合的方法额,呵呵
这怎么行 我是在学C++ 用计算机软件处理问题 又不是真的想仅仅计算学生成绩,制成表格。。。。
#include&iostream&struct&Student{ char&name[20]; int&N double&grade1; double&grade2; double&grade3; double&};int&main(){ using&namespace& Student&s[10]; cout&&&Enter&the&information&of&every&students\n&; for&(int&i=0;i&10;i++)
//输入数据 {
cout&&&#&&&i+1&&
cout&&&Name:&&;
cin.get(s[i].name,20);
while&(cin&&cin.get()!='\n')
//防止输入过多
cout&&&Number:&&;
cin&&s[i].N
cout&&&Grade1:&&;
cin&&s[i].grade1;
cout&&&Grade2:&&;
cin&&s[i].grade2;
cout&&&Grade3:&&;
cin&&s[i].grade3;
cin.get();
s[i].average=(s[i].grade1+s[i].grade2+s[i].grade3)/3; //算平均分 } cout&&&\nHere&is&the&information\n&; int&max=0,min=0; for&(int&i=0;i&10;i++)
//输出学生信息 {
cout&&&#&&&i+1&&
cout&&&Name:&&&&s[i].name&&
cout&&&Number:&&&&s[i].Number&&
cout&&&Grade1:&&&&s[i].grade1&&
cout&&&Grade2:&&&&s[i].grade2&&
cout&&&Grade3:&&&&s[i].grade3&&
cout&&&Average&grade:&&&&s[i].average&&
if&(s[max].average&s[i].average)
//计算最高最低成绩
if&(s[min].average&s[i].average)
min=i; } cout&&&The&student&gets&the&highest&grades&is&&&&s[max].name&& cout&&&The&student&gets&the&lowest&grades&is&&&&s[min].name&& return&0;}
感激涕零的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁查看: 463|回复: 4|关注: 0
一个Model多个S函数(C++)Block,有没有什么共享SimStruct的办法
一个Model里面有多个S函数的Block,现在需要一个Block的S函数去调用另一个Block的参数和里面的数据(不是用信号去连接,而是直接读取)。请问有没有大神知道?
关注者: 12
请使用工作向量来实现数据共享。
请使用工作向量来实现数据共享。
工作向量?是PWork吗?我现在用PWork都是在自身的block里面。它能作为output输出吗?这几天我找到网上说用Dwork,但是没有找到例子或者教程。请问类似Dwork或者Pwork这种工作向量作为一个输出量从block输出,让其他block读取它的信息,还是说这种工作向量可以作为一个全局的去共享呢?版主能不能给一个最简单的例子呢?小弟感激不尽
关注者: 12
此回复为最佳答案|
工作向量?是PWork吗?我现在用PWork都是在自身的block里面。它能作为output输出吗?这几天我找到网上说 ...
使用DWork工作向量,下面是一个全局变量累加的例子,你拷贝到c文件中,编译位mexw文件,再使用一个S-func模块调用即可,没有参数。
#define S_FUNCTION_NAME sfun_dwork_demo
#define S_FUNCTION_LEVEL 2
#include &simstruc.h&
/*====================*
* S-function methods *
*====================*/
/* Function: mdlInitializeSizes ===============================================
* Abstract:
*& & The sizes information is used by Simulink to determine the S-function
*& & block's characteristics (number of inputs, outputs, states, etc.).
*/
static void mdlInitializeSizes(SimStruct *S)
{
& &
& & ssSetNumContStates(S, 0);
& & ssSetNumDiscStates(S, 0);
& & if (!ssSetNumInputPorts(S, 0))
& &
& & //ssSetInputPortDirectFeedThrough(S, 0, 0);
& & if (!ssSetNumOutputPorts(S, 1))
& & ssSetOutputPortWidth(S, 0, 1);
& & ssSetNumSampleTimes(S, 1);
& & ssSetNumDWork(S, 1);
& & ssSetNumRWork(S, 0);
& & ssSetNumIWork(S, 0);
& & ssSetNumPWork(S, 0);
& & ssSetNumModes(S, 0);
& & ssSetNumNonsampledZCs(S, 0);
& & ssSetDWorkWidth(S, 0, 1);
& & ssSetDWorkDataType(S, 0, SS_DOUBLE);
& && & /* specify the sim state compliance to be same as a built-in block */
& & ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
& & /* Call terminate on exit to free memory for Simulink Coder dwork props */
& & ssSetOptions(S,
& && && && && &&&SS_OPTION_WORKS_WITH_CODE_REUSE |
& && && && && &&&SS_OPTION_EXCEPTION_FREE_CODE |
& && && && && &&&SS_OPTION_CALL_TERMINATE_ON_EXIT |
& && && && && &&&SS_OPTION_USE_TLC_WITH_ACCELERATOR);
}
/* Function: mdlInitializeSampleTimes =========================================
* Abstract:
*& & One sample time, and it's passed in as the fourth S-function parameter
*/
static void mdlInitializeSampleTimes(SimStruct *S)
{
& & ssSetSampleTime(S, 0, 1);
& & ssSetOffsetTime(S, 0, 0.0);
& & ssSetModelReferenceSampleTimeDefaultInheritance(S);
}
#define MDL_INITIALIZE_CONDITIONS
/* Function: mdlInitializeConditions ========================================
* Abstract:
*& & Initialize both continuous states to zero
*/
static void mdlInitializeConditions(SimStruct *S)
{
& & real_T *x = (real_T*) ssGetDWork(S,0);
& &&&* Initialize the dwork to 0
& &&&*/
& & x[0] = 0.0;
}
/* Function: mdlOutputs =======================================================
* Abstract:
*& && &y = x
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
& & real_T *y = ssGetOutputPortRealSignal(S,0);
& & real_T *x = (real_T*) ssGetDWork(S,0);
& & /* Return the current state as the output */
& & y[0] = x[0];
}
#define MDL_UPDATE
/* Function: mdlUpdate ========================================================
* Abstract:
*& & This function is called once for every major integration time step.
*& & Discrete states are typically updated here, but this function is useful
*& & for performing any tasks that should only take place once per integration
*& & step.
*/
static void mdlUpdate(SimStruct *S, int_T tid)
{
& & real_T *x = (real_T*) ssGetDWork(S,0);
& &
& & x[0] += 1.0;
}
/* Function: mdlTerminate =====================================================
* Abstract:
*& & No termination needed, but we are required to have this routine.
*/
static void mdlTerminate(SimStruct *S)
{
& & char*
& & char*
& & /* I free any old setting and update */
& & id = ssGetDWorkRTWIdentifier(S, 0);
& & if (id != NULL) {
& && &&&free(id);
& & }
& & ssSetDWorkRTWIdentifier(S, 0, NULL);
& & /* Type Q free any old setting and update */
& & tq = ssGetDWorkRTWTypeQualifier(S, 0);
& & if (tq != NULL) {
& && &&&free(tq);
& & }
& & ssSetDWorkRTWTypeQualifier(S, 0, NULL);
}
#ifdef&&MATLAB_MEX_FILE& & /* Is this file being compiled as a MEX-file? */
#include &simulink.c&& && &/* MEX-file interface mechanism */
#else
#include &cg_sfun.h&& && & /* Code generation registration function */
#endif
复制代码
使用DWork工作向量,下面是一个全局变量累加的例子,你拷贝到c文件中,编译位mexw文件,再使用一个S-func ...
多谢版主回答,我去试试看
Powered by

我要回帖

更多关于 大神f2有没有电信版 的文章

 

随机推荐