C primer 第六章习题6.13

//编写程序包含8个元素的int类型数组,用for循环设置数组元素,用do while循环显示元素值。

#include <stdio.h>
int main(void)
{
       int num[8],index,i,pow;

for (index=0,i=0,pow=1;index<=7;index++){
                pow*=2;
                num[index]=pow;
            do    {
            i++;
            printf("%d ",num[index]);
            } while (i<=index);
        }

return 0;
}

时间: 2024-08-25 06:40:55

C primer 第六章习题6.13的相关文章

Python核心编程(第二版) 第六章习题答案

6–1.字符串.string 模块中是否有一种字符串方法或者函数可以帮我鉴定一下一个字符串是否是另一个大字符串的一部分? 答:有,string.find(str,beg,end) 6–2.字符串标识符.修改例 6-1 的 idcheck.py 脚本,使之可以检测长度为一的标识符,并且可以识别 Python 关键字,对后一个要求,你可以使用 keyword 模块(特别是 keyword.kelist)来帮你. 1 #!/usr/bin/python 2 3 import string 4 impo

Perl语言入门:第六章习题:处理用户所指定的名字并汇报相应的姓。

37 print "\n----------------------------------_exercise_6_1--------------------------\n";     38 my %bless_function = ( #hash may be a lexical variable     39    "constructors" => "default_values",     40    "error_ha

结构体的处理(以c++primer plus 第六章习题4为例)

1 const unsigned int strsize = 50; 2 struct bop //结构体就像一个数据类型如int 使用前应该先给他一个变量如本题中的bop 3 { 4 char fullname[strsize]; // real name 5 char title[strsize]; // job title 6 char bopname[strsize]; // secret BOP name 7 int preference; // 0 = fullname, 1 = t

C primer 第六章循环 习题6.7

6.07 让用户输入一个单词,并倒序打印这个单词 #include <stdio.h>#include <string.h>int main(void){   char word[20];   size_t size;   int index; printf("Please enter a word:");   scanf("%s",word);   size=(strlen (word));   index=size--; for(;ind

学习opencv 第六章 习题十三

用傅里叶变换加速卷积,直接上代码,Mat版是Copy他人的. CvMat版 1 #include "stdafx.h" 2 #include "cv.h" 3 #include "highgui.h" 4 #include <iostream> 5 6 using namespace cv; 7 using namespace std; 8 9 void speedy_convolution(const CvMat* A,const

第六章习题

本来准备模仿前几题建树来做,但是发现判断部分还是要写出答案那样. 1 #include <iostream> 2 #include <cstdio> 3 4 5 using namespace std; 6 7 struct Node 8 { 9 bool have_value; 10 int w; 11 int d; 12 13 Node *left,*right; 14 15 Node():left(NULL),right(NULL),have_value(false){} 1

核心编程第二版第六章习题

6–1. 字符串.string 模块中是否有一种字符串方法或者函数可以帮我鉴定一下一个字符串是否是另一个大字符串的一部分? 成员关系操作符in obj in seq 6–3. 排序(a) 输入一串数字,从大到小排列之.(b) 跟 a 一样,不过要用字典序从大到小排列之 (a) num=raw_input(">>") lisnum=list(num) list.sort(lisnum) print lisnum (b)没看懂 6–4. 算术. 更新上一章里面你的得分测试练习方

动态规划习题--九章算法第五、六章习题

1.Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bott

Objective-C 程序设计(第六版)第六章习题答案

1. 1 int value1,value2; 2 printf("请输入两个整数,用逗号隔开:"); 3 scanf("%d,%d",&value1,&value2); 4 5 if (value1 % value2 == 0) { 6 printf("可以整除\n"); 7 } 8 printf("不能整除\n"); 9 2.  main函数部分 1 double value1, value2; 2 cha