华南理工大学 高级程序设计语言 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 {

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值