用C语言写 任意输入10个整数,将这10个数按相反的次序输出。

[复制链接]
查看11 | 回复1 | 2009-6-20 21:46:52 | 显示全部楼层 |阅读模式
#include "stdio.h"int main(){ int arr[10],i; /*输入十个整数*/ printf("请输入十个整数:\n"); for(i=0;i=0;i--)printf("%d ",arr);
return 0;}
回复

使用道具 举报

千问 | 2009-6-20 21:46:52 | 显示全部楼层
基本的堆栈思想嘛。#include"stdio.h"#define SIZE 10main(){int num=0;int choice,d;int data[SIZE];for(;;){printf("\npush(1), pop(0) or exit(2)?");scanf("%d",&choice);if (choice==1) { printf("Enter the number you what to push in.");scanf("%d",&d); if (num==SIZE) printf("Stack full");else {data[num]=d;num++; } }else if (choice==0) { if(num==0) printf("Stack empty");else{d=data[num-1];printf("The number poped up is %d",d);num--;} }else if (choice==2) exit();else printf("Input another choice, please");}}前几天刚好编过, 我知道不是完全切题,但是很有用的参考了。。hope it helps~ 给你一个参考 最后还得你自己想哦~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行