0% found this document useful (0 votes)
8 views5 pages

Project C++ PtukExam

Uploaded by

ergrabah2017
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Project C++ PtukExam

Uploaded by

ergrabah2017
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Tel:PtukExam

Tel:PtukExam
>include <iostream#
;using namespace std
{ )(int main
;int studentID
;" :cout << "Enter your student ID
;cin >> studentID
;int a=studentID
;int lastDigit = studentID%10
;int c=0
;int id1=0
;int height=0
{while(studentID!=0)
;int d=studentID%10
;studentID/=10
};id1=id1*10+d
{while(c<4)
;int d=id1%10
;id1/=10
;++c
};height+=d
;cout << "the last digit of your student ID=" << lastDigit<< endl

{ switch (lastDigit)
:case 0
{ :case 1
;int width
{for(int i=0;i<4;i++)
;int d=a%10
;width+=d
Tel:PtukExam
;a=a/10
}
{ for (int i = 0; i < height; i++)
{ for (int j = 0; j < width; j++)
;" *" << cout
}
;cout << endl
}
;break
}
:case 2
{ :case 3
{ for (int i = 1; i <= height; i++)
{ for (int j = 1; j <= i; j++)
;" *" << cout
}
;cout << endl
}
;break
}
:case 4
{ :case 5
{ for (int i = 1; i <= height; i++)
{ for (int j = height - i; j > 0; j--)
;" " << cout
}
{ for (int j = 1; j <= 2 * i - 1; j++)
;" *" << cout
}
;cout << endl
Tel:PtukExam
}
;break
}
:case 6
{ :case 7
{ for (int i = height; i > 0; i--)
{ for (int j = i; j > 0; j--)
;" *" << cout
}
;cout << endl
}
;break
}
:case 8
{ :case 9
;height=(height*2)
;cout<<"height= "<<height-1<<endl
;height=height/2
{ for (int i = 0; i < height; i++)
{ for (int j = 0; j < (height - i); j++)
;" " << cout
}
{ for (int k = 1; k <= (i * 2) - 1; k++)
;"*" << cout
}

;cout << endl


}
{ for (int i = 0; i < height; i++)
{ for (int j = 1; j <=i; j++)
Tel:PtukExam
;" " << cout
}
{ for (int k = 1; k <= ( height-i)*2-1; k++)
;"*" << cout
}

;cout << endl


}}
:default
;".cout << "Invalid ID digit for shape determination
}

;return 0
}

You might also like