华南理工大学 高级程序设计语言 c++ ,2017华南理工大学网络教育《高级语言程序设计C++》平时作业...
4.函數create從鍵盤輸入整數序列,以輸入0為結束。按輸入順序建立單向鏈表并返回表頭。
struct node{int data; node * next;};
node * create()
{
node *head, *p, *q; p = new node; head = p; cin>>p->data;
while( p->data != 0 ) {
q = p;
p = new node ; q->next = p; cin>>p->data; }
if (head == p) head = NULL;
else q->next = p ; if (head == NULL) delete p ; return head; }
5.以下程序求方程的全部整數解:
3x + 2y - 7z = 5 ( 0 ≤ x, y, z ≤ 100 )
#includevoid main() { int x, y, z ;
for( x=0; x<=100; x++ ) for( y=0; y<=100; y++ ) { if( ( z=3*x+2*y-5 ) % 7 )
break ;
//求出z的值
s=s+(1.0/(n*n*n) ;
if( z<=100&&z>=0 ) //檢查z的范圍
cout << \ } }
三、程序設計
1. 編寫函數輸出以下形狀的圖形,其中構成圖形的數字和輸出的行數通過參數傳送。
1 2 2 2 3 3 3 3 3 4 4 4 4 4 4 4
#includevoid main() {
int i,n;
for (i=0;i<5; i++){ for (n=0;n<2*i-1;n++){ cout<
cout<2. 請編程序,輸入兩個正整數啊a和b(a
the factors of 6 : 2 3
the factors of 7 : no factor
the factors of 8 : 2 4
#include using namespace std; void printFactor(int i); void main() {
int numA,numB;
cout<
cin>>numA>>numB;
for (int i=numA;i<=numB;i++)
{
printFactor(i);
} }
void printFactor(int i) {
cout<
for (int k=2;k
if (i%k==0) {
fact[n]=k; n++; } }
if (n==0)
{
cout<
} else {
總結
以上是生活随笔為你收集整理的华南理工大学 高级程序设计语言 c++ ,2017华南理工大学网络教育《高级语言程序设计C++》平时作业...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c实现多语言编程,C/C++编程中多国语
- 下一篇: c 语言中下标运算符,详解C++中二进制