VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

搜索
查看: 874|回复: 3

[已解决]报错":"没有从"int*"到"int"的转换

[复制链接]
66_avatar_middle
最佳答案
0 
在线会员 发表于 2021-11-5 14:29:18 | 显示全部楼层 |阅读模式
#include <iostream>
#include <iomanip>
#include <math.h>
#include "inc.h"

using namespace std;


//int g_sum = 0;
//void print_msg();

int main()
{
        int stu_no[] = {5, 8, 9, 0, 2, 1, 4, 7, 6, 3};
        int i;
        int max_no = stu_no[0];
        int min_no = stu_no[0];
        for (i = 1; i <= (end(stu_no) - begin(stu_no));i++)
        {
                max_no = max_no > stu_no[i] ? max_no : stu_no;
                min_no = min_no < stu_no[i] ? min_no : stu_no;
                cout<<max_no<<endl;
                cout<<min_no<<endl;
        }
        return 0;
}
最佳答案
00_avatar_small
2021-11-5 17:35:53
三目运算符数据类型不匹配
  1. int main()
  2. {
  3.         int stu_no[] = { 5, 8, 9, 0, 2, 1, 4, 7, 6, 3 };
  4.         int i;
  5.         int max_no = stu_no[0];
  6.         int min_no = stu_no[0];
  7.         for (i = 1; i <= (end(stu_no) - begin(stu_no)); i++)
  8.         {
  9.                 max_no = max_no > stu_no[i] ? max_no : stu_no[i];//少了[i]
  10.                 min_no = min_no < stu_no[i] ? min_no : stu_no[i];//少了[i]
  11.                 cout << max_no << endl;
  12.                 cout << min_no << endl;
  13.         }
  14.         return 0;
  15. }
复制代码




上一篇:为什么用 &amp; 而 不用 ==
下一篇:C++控件的属性问题
00_avatar_middle
最佳答案
13 
在线会员 发表于 2021-11-5 17:35:53 | 显示全部楼层    本楼为最佳答案   
bestAnswer
三目运算符数据类型不匹配
  1. int main()
  2. {
  3.         int stu_no[] = { 5, 8, 9, 0, 2, 1, 4, 7, 6, 3 };
  4.         int i;
  5.         int max_no = stu_no[0];
  6.         int min_no = stu_no[0];
  7.         for (i = 1; i <= (end(stu_no) - begin(stu_no)); i++)
  8.         {
  9.                 max_no = max_no > stu_no[i] ? max_no : stu_no[i];//少了[i]
  10.                 min_no = min_no < stu_no[i] ? min_no : stu_no[i];//少了[i]
  11.                 cout << max_no << endl;
  12.                 cout << min_no << endl;
  13.         }
  14.         return 0;
  15. }
复制代码
75_avatar_middle
最佳答案
23 
online_supermod 发表于 2021-11-5 19:01:04 | 显示全部楼层
一个是整形指针 一个是整形  有区别的
50_avatar_middle
最佳答案
0 
在线会员 发表于 2021-11-5 21:55:09 | 显示全部楼层
虽然指针也是INT型,但是在C++里面是指针就是指针不是INT
您需要登录后才可以回帖 登录 | 加入驿站 qq_login

本版积分规则

×【发帖 友情提示】
1、请回复有意义的内容,请勿恶意灌水;
2、纯数字、字母、表情等无意义的内容系统将自动删除;
3、若正常回复后帖子被自动删除,为系统误删的情况,请重新回复其他正常内容或等待管理员审核通过后会自动发布;
4、感谢您对VC驿站一如既往的支持,谢谢合作!

关闭

站长提醒上一条 /2 下一条

QQ|小黑屋|手机版|VC驿站 ( 辽ICP备09019393号-4 )|网站地图wx_jqr

GMT+8, 2023-6-10 04:47

Powered by CcTry.CoM

© 2009-2021 cctry.com

快速回复 返回顶部 返回列表