C语言switch结构问题

[复制链接]
查看11 | 回复2 | 2007-7-30 11:26:19 | 显示全部楼层 |阅读模式
直接用几个printf输出不就OK了嘛
回复

使用道具 举报

千问 | 2007-7-30 11:26:19 | 显示全部楼层
printfmain():for:1 12 123 1234 12345 12345 1234 123 12 1
回复

使用道具 举报

千问 | 2007-7-30 11:26:19 | 显示全部楼层
#include void main(){ int i = 0; int j = 0; for(i = 1;i = 1;i --) {for(j = 1;j #include int main(int argc, char* argv[]){ int i,j,p; for (i=1,j=1; i >= 1; i+=j) {if (i>5) j=-1;switch(i){ case 1:printf("1\n");break; case 2:printf("12\n");break; case 3:printf("123\n");break; case 4:printf("1234\n");break; case 5:printf("12345\n");break; default :printf("\n") ;} } system("pause"); return 0;}/////////////////////////////////////////////////////////不使用switch结构://///////////////////////////////////////////////////////#include #include int main(int argc, char* argv[]){ int i,j,p; for (i=1,j=1; i >= 1; i+=j) {
if (i>5) j=-1; if (i!=6) for (p = 1; p <= i; p++) printf("%d",p);
printf("\n"); } system("pause"); return 0;}
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行