没有呀!你的程序后缀名是什么?应该是.cpp
// Mytest.cpp#include <iostream.h>
#include <stdio.h>void main()
{
cout << "This is cout test\n";
printf("This is printf test\n");
}
// Mytest.cpp#include <iostream.h>
#include <stdio.h>void main()
{
cout << "This is cout test\n";
printf("This is printf test\n");
}
#include <stdio.h>
#include <string.h>
#include <iostream.h>void main(int n, int r,int k)
{
int i,j;
for (i=n;i>=r;i--)
{
if((i!=n)&&(k!=r))
{
for(j=1;j<=(k-r)*3;j++)
//cout<<" ";
printf(" ");
}
//cout<<" "<<i;
printf("%3d",i);
if(r>1)
comb(i-1,r-1,k);
else
//cout<<"\n";
printf("\n");
}
}
cout带有缓冲机制,而printf没有缓冲。
建议除非真的有必要,否则不要混用。因为这是很不好的做法。如果一定要混用的话,可以试试在cout<<"\n";之后加上cout.flush();
#include <stdio.h>
#include <iostream.h>void comb(int n, int r,int k);void main()
{
int n,r,k;
n=5;r=3;k=3;
comb(n,r,k);
//cout<<"*********************\n";
printf("*********************\n");
cout<<"*********************\n";
// printf("*********************\n");
}void comb(int n, int r,int k)
{
int i,j;
for (i=n;i>=r;i--)
{
if((i!=n)&&(k!=r))
{
for(j=1;j<=(k-r)*3;j++)
cout<<" ";
//printf(" ");
}
cout<<" "<<i;
//printf("%3d",i);
if(r>1)
comb(i-1,r-1,k);
else
cout<<"\n";
//printf("\n");
}
}