Lỗi c++: was not declared in this scope


tại sao e lại bị lỗi ntn ạ?

#include<iostream>
using namespace std;
int main ()
{
    int n;
    int sohoanchinh=0,songuyento=0;
    cout<<"n= ";cin>>n;
    for (int i=1;i<=n;i++)
    {
        int d=0,s=0;
        for (int j=1;j<=i;j++)
        if (i%j==0) d++;
        if (i%j==0) s=s+i;
        if (d==2) songuyento++;
        if(s==i) sohoanchinh++;
    }
    cout<<"co "<<songuyento<<" so nguyen to";
    cout<<"co "<<sohoanchinh<<" so hoan chinh";
}

merged to the #1 post by noname00

Lệnh for thứ 2 cho cặp {} vào.

3 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?